/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 * 
 * @file:   Album.js
 * @path:   js-src/album/
 * @author: jiegang@qiyi.com
 * @date:   2015-01-11
 */

var GLOBAL = GLOBAL || {};
GLOBAL.user = {
    area: "sh"
};
GLOBAL.currentDate = Com.date.getCurrentDate();



define(
    '../ancestor/Ancestor',['require','exports','module'],function(require, exports, module) {


        ///import js-src/lib/
        ///import js-src/com/

        window.Ancestor = window.Ancestor || {
            version: '1.0'
        };


    }
);
/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 *
 * @file:   Ancestor.Dao.js
 * @path:   js-src/Ancestor/
 * @desc:   负责本模块的远程调用的静态对象
 * @author: jiegang@qiyi.com
 * @date:   2015-01-12
 */
define(
    '../ancestor/Ancestor.Dao',['require','exports','module'],function(require, exports, module) {

        Ancestor.Dao = (function() {
            var config = Ancestor.Config;

            var ajax = function(options, authPath) {
                if (authPath)
                    $.ajax($.extend(options, {
                        beforeSend: function(request) {
                            var authBase = Ancestor.Util.getAuth(authPath);
                            request.setRequestHeader('Sign', authBase.sign);
                            request.setRequestHeader("Time", authBase.clientTime);
                            request.setRequestHeader("From", authBase.from);
                            request.setRequestHeader("UserName", (auth.baseInfo.authInfo==null) ? "" : escape(auth.baseInfo.authInfo.userName).toLocaleLowerCase().replace(/%u/gi, '\\u'));
                        }
                    }));
                else
                    $.ajax(options);
            };

            // 获取配频道配置数据
            var getType = function(data, callback) {
                var options = {
                    url: config.CONFIGS_API.url,
                    dataType: 'json',
                    data: data,
                    method: 'get',

                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                ajax(options, "/configs");

            };

            var getSuggestData = function(url, data, callback) {

                var request = {};
                request.url = url;
                request.type = 'get';

                if (data.needCookie)
                    request.needCookie = true;

                request.params = data;

                data = {
                    request: JSON.stringify(request)
                };

                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                ajax(options, '/redirect');
            };

            var getQipuDataById = function(item, callback) {
                var url = Ancestor.Config.QIPU_URL.replace("${QIPUID}", item.qipuId);

                var request = {};
                request.url = url;
                request.type = 'get';

                var data = {
                    request: JSON.stringify(request)
                };

                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    method: 'post',
                    data: data,
                    success: function(data) {
                        callback.call(this, data, item);
                    },
                    error: function(data) {
                        callback.call(this, data, item);
                    }
                };

                ajax(options, '/redirect');
            };

            // 获取分类
            var getuniversalCodeData = function(url, data, callback) {

                var options = {
                    url: url,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                ajax(options, url.split('api')[1]);
            };

            // XMLHttp Request
            var _getXHR = function() {
                return new XMLHttpRequest() || new ActiveXObject('Msxml2.XMLHTTP') || new ActiveXObject('Microsoft.XMLHTTP');
            };

            var qichuanUploadFile = function(data, handler) {
                var self = this;
                var xhr = _getXHR();
                var precent = 0;
                xhr.open('POST', data.url, true);
                // xhr.setRequestHeader('Content-Type', 'multipart/form-data');
                for (var key in data.headers) {
                    xhr.setRequestHeader(key, data.headers[key]);
                }

                xhr.upload.onprogress = function(e) {
                    var data = xhr.responseText ? JSON.parse(xhr.responseText) : null;
                    if (e.lengthComputable) {
                        precent = (e.loaded / e.total) * 100;
                        if (handler.onProgress) {
                            handler.onProgress.apply(self, [precent, data]);
                        }
                    }
                };

                xhr.onreadystatechange = function() {
                    var data = xhr.responseText ? JSON.parse(xhr.responseText) : null;
                    if (xhr.readyState == 4) {
                        var stat = xhr.status;
                        if ((stat >= 200 && stat < 300) || stat == 304 || stat == 1223 || stat === 0) {
                            if (handler.onFinish) {
                                handler.onFinish.call(self, data);
                            }
                        } else {
                            if (handler.onFail) {
                                handler.onFail.call(self, data);
                            }
                        }
                    }
                };

                var formData = new FormData();
                formData.append('businessType', data.headers['businessType']);
                formData.append('fileid', data.headers['file_id']);
                formData.append('imagefile', data.file);

                // xhr.send(data.file || null);
                xhr.send(formData);


                return xhr;
            };


            var qichuanRequestFile = function(options, callback) {
                options = options || {};
                var headers = options.headers || {};

                var options = {
                    url: options.url + '?t=' + new Date().getTime(),
                    // url: options.url,
                    dataType: 'json',
                    // data: data,
                    headers: headers,
                    method: 'get',
                    success: function(data) {
                        if (data && data.code == 'A00000') {
                            callback.call(this, data);
                        } else {
                            console.log('get access fail.');
                            callback.call(this, data);
                        }
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                ajax(options, false);

            };

            var platSettings = function(options, callback) {
                var options = {
                    url: '/api/channel/getPlatSettings',
                    dataType: 'json',
                    data: options,
                    method: 'post',

                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                ajax(options, "/channel/getPlatSettings");
            };

            var redirectRequest = function(options, callback) {
                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: options,
                    method: 'post',
                    beforeSend: function(request) {
                        var auth = Ancestor.Util.getAuth('/redirect');
                        request.setRequestHeader('Sign', auth.sign);
                        request.setRequestHeader("Time", auth.clientTime);
                        request.setRequestHeader("From", auth.from);
                    },
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                ajax(options, "/redirect");
            };

            return {
                getType: getType,
                qichuanRequestFile: qichuanRequestFile,
                qichuanUploadFile: qichuanUploadFile,
                getSuggestData: getSuggestData,
                platSettings: platSettings,
                getuniversalCodeData: getuniversalCodeData,
                getQipuDataById: getQipuDataById,
                redirectRequest: redirectRequest,
                ajax: ajax
            };
        })();
    }
);
/**
 * Copyright 2013 Qiyi Inc. All rights reserved.
 * 
 * @file: Ancestor.Base.js
 * @path: js-src/Ancestor/
 * @desc: Ancestor模块下基础业对象类
 * @author: lichuning@qiyi.com
 * @date: 2013-04-10
 */
///import js-src/lib/
///import js-src/com/

define('../ancestor/Ancestor.Grid',['require','exports','module'],function(require, exports, module) {

    Ancestor.Grid = function(options) {};
    /**
     * 每个Action都设置一个初始化方法 用于初始化Ancestor 原型对象，默认不重复初始化
     *
     * @param {Boolean}
     *            force 是否强制初始化
     *
     */
    Ancestor.Grid.prototype = $.extend(true, {}, Com.Grid, {
        filterDataWhenBatchOper: function(data, filter) {
            filter = filter || function(item) {
                return !item.del;
            };

            data = $.grep(data, function(item) {

                return filter(item);
            });

            return data;
        },
        /**
         * 素材库查询方法
         * @param params 查询参数，采用jquery formSerialize
         * @param callback
         */
        query: function(callback) {

            var self = this;
            var $grid = self.$grid;

            var params = this.getParam();

            $grid.jqGrid('setGridParam', {
                postData: params
            }).trigger('reloadGrid', [{
                page: 1
            }]);

        },
        getParam: function() {

            var self = this;
            var $container = self.options.$container;
            var $grid = self.$grid;
            Com.Grid.overridePostData($grid);
            var params = {};
            var $elements = $.makeArray($container.find('form.query').prop('elements'));

            $.each($elements, function() {
                if (this.name) {
                    var key = $(this).attr('data-key');
                    if (key) {
                        params[this.name] = $(this).attr(key) || '';
                    } else {
                        params[this.name] = $(this).val();
                    }
                }
            });

            return params;
        },

        echoQuery: function() {
            var self = this;
            var $container = self.options.$container;

            this.query();

        },

        getGrid: function() {
            return this.$grid;
        },

        run: function(options, callback) {


            this.bindEvent();
            this.echoQuery();
            this.initGrid.call(this, options, callback);

        },

        setType: function(type) {
            this.options.type = type;
        },

        getType: function() {
            return this.options.type;
        },

        getGridConfig: function(table, tableColModel) {
            var self = this;
            var tableConfig = $.extend(true, {}, table || self.config.TABLE);
            var colModel = tableConfig.colModel;
            var newColModel = [];
            var colModelConfig = tableColModel || self.config.TABLE_COLMODEL_CONFIG;

            $.each(colModel, function(i, model) {
                newColModel.push(colModelConfig[model]);
            });
            tableConfig.colModel = newColModel;
            return tableConfig;
        },

        initGrid: function(options, callback) {
            var self = this;

            var gridConfig = self.getGridConfig();

            var $gridContainer = self.options.$container;

            var type = self.getType();
            var $pager = $gridContainer.find('div.pager');
            var $grid = $gridContainer.find('table.grid');
            var params = self.getParam();
            options = $.extend(true, {
                pager: $pager,
                mtype: 'post',

                postData: $.extend(true, {
                    type: type

                }, params),

                sortname: 'createTime',
                sortorder: 'desc',


                multiselect: true,

                multiselectWidth: 30

            }, gridConfig, options);

            $grid.jqGrid('scroll', {});
            $grid.jqGrid(options);

        },

        bindEvent: function() {
            var self = this;
            var $container = this.options.$container;
            var $form = $container.find('form[name="basicFrm"]');

            /*
             * 绑定时间
             *
             */
            //$.datepicker.setDefaults( $.datepicker.regional[ "" ] );

            $container.find("#StartTime").datetimepicker({
                onClose: function(selectedDate) {
                    $("#EndTime").datepicker("option", "minDate", selectedDate);
                }

            });

            $container.find("#EndTime").datetimepicker({
                onClose: function(selectedDate) {
                    $("#StartTime").datepicker("option", "maxDate", selectedDate);
                }
            });

            $form.find('button[type="reset"]').click(function() {
                self.resetQueryForm();
            });
        },

        resetQueryForm: function() {
            var self = this;
            var $container = this.options.$container;
            var $form = $container.find('form[name="basicFrm"]');
            // 从suggest获得的数据都需要清空
            $form.find('input[data-key]').removeAttr('data-id');
        },

        reload: function(params) {
            var type = this.getType();
            params = $.extend(true, {
                type: type
            }, params);
            this.$grid.jqGrid('setGridParam', {
                postData: params
            }).trigger('reloadGrid');
        },

        // 基本数据请求队列
        ajaxBasicRequestQueue: (function() {
            var Queue = [];

            var pushData = function(obj) {
                Queue.push(obj);
            };
            var getQueueLen = function() {
                return Queue.length;
            };
            var getQueueData = function() {
                return Queue;
            };
            var clearQueueData = function() {
                Queue = [];
            };

            return {
                pushData: pushData,
                getQueueLen: getQueueLen,
                getQueueData: getQueueData,
                clearQueueData: clearQueueData
            };

        })(),

        ajaxBasicRequestLen: -1,
        intverId: null,

        // 处理请求队列
        ajaxBasicRequestManage: (function() {

            var self = null,
                fct = null,
                tryNumbers = 10000; //尝试10000次

            var init = function(obj, func) {
                self = obj;
                fct = func;
                start();
            };

            var start = function() {
                var len = self.ajaxBasicRequestQueue.getQueueLen();
                if (len === 0) return;

                if (self.ajaxBasicRequestLen == len || tryNumbers == 1) {
                    clearInterval(self.intverId);
                    fct(self);
                    self.ajaxBasicRequestQueue.clearQueueData();
                } else if (self.ajaxBasicRequestLen != -1) {
                    return;
                } else {
                    var queue = self.ajaxBasicRequestQueue.getQueueData();
                    self.ajaxBasicRequestLen = 0;

                    $.each(queue, function(i, item) {
                        item.func(function() {
                            self.ajaxBasicRequestLen++;
                        });
                    });
                    self.intverId = setInterval(start, 10);
                }
                tryNumbers--;
            };
            return {
                init: init
            };
        })(),
    });

});
/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 *
 * @file:   Ancestor.Dao.js
 * @path:   js-src/Ancestor/
 * @desc:   负责本模块的远程调用的静态对象
 * @author: jiegang@qiyi.com
 * @date:   2015-01-11
 */
define('../ancestor/Ancestor.Config',['require','exports','module'],function(require, exports, module) {


    ///import js-src/lib/
    ///import js-src/com/
    Ancestor.Config = (function() {
        var REQUEST_FAIL = "接口响应超时,请稍后再试！";
        var QICHUAN = {

            //image_requestURL: 'http://upload.iqiyi.com/request_image_upload',
            image_requestURL_test: 'http://upload.iqiyi.com/request_image_upload',

            image_uploadURL: 'http://upload.iqiyi.com/image_upload',
            image_uploadURL_inner: 'http://upload.qiyi.domain/image_upload',
            image_uploadURL_test: 'http://upload.iqiyi.com/image_upload',

            deviceId: 'LEGO-uploader',
        };

        var EPG_AUTH = {

            From: 'frontend', // 来源
            key: '7dpHGKMy4hAh3DmC' // 密钥

        };

        var CONFIGS_API = {
            url: '/api/configs'
        };

        // 直转点 频道名称
        var CATEGORY_NAME = [];

        // 直播类型
        var LIVE_TYPE = [];

        // 频道分类
        var CHANNEL_TYPE = [];


        // 日志分类
        var LOG_TYPE = [];

        // 备播库标色提示
        var APC_WARNING = {
            NORMAL: 'black',
            RED: 'red',
            ORANGE: '#ffa800'
        };

        var PLATFORM_TYPE = null;
        var PLATFORM_REFER = null;

        // 奇谱url
        var QIPU_URL = (function() {
            var qipuUrl = auth.dev() ? 'http://qipu-test.qiyi.domain/int/entity/nocache/${QIPUID}.json' : 'http://qipu.qiyi.domain/int/entity/nocache/${QIPUID}.json';
            return qipuUrl;
        })();

        return {
            EPG_AUTH: EPG_AUTH,
            LIVE_TYPE: LIVE_TYPE,
            CHANNEL_TYPE: CHANNEL_TYPE,
            QICHUAN: QICHUAN,
            CONFIGS_API: CONFIGS_API,
            LOG_TYPE: LOG_TYPE,
            APC_WARNING: APC_WARNING,
            PLATFORM_REFER: PLATFORM_REFER,
            PLATFORM_TYPE: PLATFORM_TYPE,
            QIPU_URL: QIPU_URL,
            REQUEST_FAIL: REQUEST_FAIL,
            CATEGORY_NAME:CATEGORY_NAME
        };


    })();

});
/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 *
 * @file:   Ancestor.Util.js
 * @path:   js/Ancestor/
 * @desc:
 * @author: jiegang@qiyi.com
 * @date:   2015-01-11
 */
define('../ancestor/Ancestor.Util',['require','exports','module'],function(require, exports, module) {


    ///import js-src/lib/
    ///import js-src/com/

    Ancestor.Util = (function() {

        Date.prototype.format = function (format) {
        var o = {
                  "M+" : this.getMonth() + 1, //month
                  "d+" : this.getDate(), //day
                  "h+" : this.getHours(), //hour
                  "m+" : this.getMinutes(), //minute
                  "s+" : this.getSeconds(), //second
                  "q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
                  "S" : this.getMilliseconds() //millisecond
              }

              if (/(y+)/.test(format)) {
                  format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
              }

              for (var k in o) {
                  if (new RegExp("(" + k + ")").test(format)) {
                      format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
                  }
              }
              return format;
          };

        // 组装 sign
        var authorization = function(options) {
            var rawSign = options.url + options.clientTime + Ancestor.Config.EPG_AUTH.key;
            return md5(rawSign);
        };

        /**
         * 设置截图编辑的整体，包括截图、幻灯片、上传三个部分
         * @param $imgcrop Object 整体的DOM结构，jQuery Object
         * @param images Array<String> 初始化用的图片URL数组
         * @param width 如果有幻灯片的话，幻灯片部分的宽度
         */
        var imageCrop = function($imgcrop) {
            // try{
            var $slideshow = $imgcrop.find('.slideshow');
            var $enableBtn = $imgcrop.find('button.button-enable');
            var $uploadBtn = $imgcrop.find('input.uploadButton');
            var $btnOnline = $imgcrop.find('button.button-online');
            var gallery, t, flag;
            // 设置下面的缩略图
            $slideshow.gallery({
                thumbnail: '.item',
                prevButton: $slideshow.find('button.left'),
                nextButton: $slideshow.find('button.right')
            });
            gallery = $slideshow.data('gallery');
            t = gallery.totalItems;
            // 设置上传图片按钮
            if ($uploadBtn.length) {
                $uploadBtn.uploadDialog({
                    gallery: $imgcrop.find('.gallery'),
                    onStart: function() {
                        gallery.update();
                        gallery.scrollTo(t);
                    }
                });
            }
            $(window).resize(function(e) {
                gallery.update();
            });
            // 设置截图控件
            $imgcrop.imageCrop({
                'gallery': '.gallery',
                'cropimg': '.cropimg',
                'results': '.results'
            });
            // 设置激活按钮
            if ($('#_entityId').val()) {
                $enableBtn.click(function(e) {
                    $imgcrop.data('imageCrop').enable();
                    $enableBtn.attr('disabled', true);
                    gallery.scrollTo(0);
                });
                $imgcrop.data('imageCrop').disable();
                $enableBtn.attr('disabled', false);
            } else {
                $imgcrop.data('imageCrop').enable();
                $enableBtn.attr('disabled', true);
                $enableBtn.hide();
            }
          $imgcrop.find('.header input').enable();
            if ('1' === $('#ThriftVideoMakeStatus').val() && '1' != $('#entityType').val()) {
                $btnOnline.show();
            } else {
                $btnOnline.hide();
            }
            // 设置在线视频截图
            /*
            if ($btnOnline.length) {
                $('#AlbumEditVideoShot').videoShot({
                    onFinish: function(area, images) {
                        var data = [];
                        $.each(images, function(index, image) {
                            data.push({
                                shot: true,
                                url: image,
                                area: area
                            });
                        });
                        $imgcrop.data('imageCrop').addImages(data);
                    }
                });
                $btnOnline.click(function(e) {
                    $('#AlbumEditVideoShot').dialog('open');
                });
            }
            */

            // }catch(e){}
        };


        /**
         * 限制输入框中字符个数，一个汉字相当于两个字符，wordCount是最多允许的汉字个数
         * @param  {jquery  object}  $des  限制字符个数的输入框
         * @param  {Number}  wordCount     允许输入的最多汉字个数,默认为450个汉字
         * @param  {Boolean} isFilterChars 是否过滤输入内容，true过滤，false或undefined不过滤
         * @param  {Array}  filterChars    需要过滤的字符集，如['$','.']，意为全局过滤 $ *                                 和 .
         */
        var limitWordCount = function($des, wordCount, isFilterChars, filterChars) {
            wordCount = wordCount || 450;
            var t = function(textarea) {
                var $textarea = $(textarea);
                var text = $textarea.val();
                if (isFilterChars) {
                    // text = Com.string.filterSpecialChars(text, filterChars);
                    $textarea.val(text);
                }
                var length = Com.string.getStrLength(text);
                if (length > wordCount * 2) {
                    $textarea.val(Com.string.substrCn(text, wordCount));
                }
                text = $textarea.val();
                length = Com.string.getStrLength(text);
                $textarea.parent().find('span.leftWordsCount').text(wordCount - Math.round(length / 2));
            };
            $des.bind({
                input: function() {
                    t(this);
                },
                propertychange: function() {
                    t(this);
                },
                keyup: function() {
                    t(this);
                }
            }).trigger('keyup');
            $des.keyup();
        };

        getParam = function($obj) {

            var $container = $obj;
            var params = {};
            var $form = $obj;

            var $elements = $.makeArray($form.prop('elements')).filter(function() {
                return true; //this.name; 
            });

            var name;
            var key;
            $.each($elements, function() {
                name = this.name;
                if (name) {

                    if (this.type == 'radio') {
                        params[name] = $('input[name="' + name + '"]:checked').val() || '';
                    } else
                        params[name] = $.trim($(this).val()) || '';

                }

            });

            params['logoUrl'] = imageObject($obj);
            return params;

        };

        imageObjectEcho = function($form, value) {

            if (value) {
                value = ('object' == typeof(value) ? value : JSON.parse(value || '[]'));
            } else {
                value = null;
            }
            if (!value) {
                return;
            }

            var imageObject = value;
            var filterType = function(type) {
                var imageData = null;
                $.each(imageObject, function(index, value) {
                    if (value.useType == type) {
                        imageData = value;
                    }
                });
                return imageData;
            };
            var spathToURL = function(images, spath) {
                var url = null;
                $.each(images, function(index, image) {
                    if (spath === image.spath) {
                        url = image.url;
                    }
                });
                return url;
            };

            $form.find('div.module-container-screen-crop').each(function(index, element) {
                var $croparea = $(this);
                var imageCrop = $croparea.data('imageCrop');
                var useType = 699; //parseInt($croparea.find('input[name="useType"]').val(), 10);
                var imageData = filterType(useType);
                var imageRank = imageData && imageData.contentRank ? imageData.contentRank : 0;
                var images = [],
                    results = {};

                if (!imageData) {
                    return;
                }

                // 回显图片分级的选项
                $croparea.find('input[name^="contentRank"]').each(function(key, value) {
                    value.checked = (imageRank == value.value);
                });

                $.each(imageData.materials, function(index, material) {
                    //images.push(material.bigThumbUrl || material.location);
                    // todo: type
                    images.push({
                        spath: material.location,
                        url: material.url,
                        data: material
                    });
                });
                $.each(imageData.images, function(index, image) {
                    var scale = image.editInfo.scale;
                    var cutPosition = image.editInfo.cutPosition.split(',');
                    var width = scale.substring(0, scale.indexOf(':'));
                    var height = scale.substring(scale.indexOf(':') + 1);
                    results[width + '-' + height] = {
                        spath: image.materialLocation,
                        imgsrc: spathToURL(images, image.materialLocation),
                        w: width,
                        h: height,
                        x1: parseInt(cutPosition[0], 10),
                        y1: parseInt(cutPosition[1], 10),
                        x2: parseInt(cutPosition[0], 10) + parseInt(cutPosition[3], 10),
                        y2: parseInt(cutPosition[1], 10) + parseInt(cutPosition[2], 10),
                        data: image
                    };
                });
                imageCrop.addImages(images, function() {
                    imageCrop.setValue(results);
                });
            });
        };


        imageObject = function($form) {
            var imageObject = [];
            $form.find('div.module-container-screen-crop').each(function(index, element) {
                var $croparea = $(this);
                var useType = parseInt($croparea.find('input[name="useType"]').val(), 10);
                var contentRank = parseInt($croparea.find('input[name^="contentRank"]:checked').val(), 10) || 0; // 默认图片分级是无分级，0
                var testFlag = 0;
                var imageData = {
                    materials: [],
                    images: [],
                    useType: 699, //useType,
                    contentRank: contentRank // 图片分级的需求，默认是无分级
                };
                $croparea.find('.gallery img').each(function(index, material) {
                    var $material = $(material);
                    if (true === $material.data('loading')) {
                        return;
                    }
                    var tmp = $material.data('data') || {
                        // @todo
                        'location': $material.data('spath') || '',
                        'url': $material.attr('src'),
                        'fromType': $material.data('type'),
                        'area': 'bj', //$material.data('area'),
                        'width': $material.data('width'),
                        'height': $material.data('height')
                    };
                    imageData.materials.push(tmp);
                    testFlag++;
                });
                $.each($croparea.data('imageCrop').getValue(), function(index, value) {
                    var tmp = $.extend(value.data, {
                        materialLocation: value.spath || value.imgsrc || '',
                        editInfo: {
                            cutPosition: [value.x1, value.y1, value.y2 - value.y1, value.x2 - value.x1].join(','),
                            scale: value.w + ':' + value.h
                        }
                    });
                    imageData.images.push(tmp);
                    //testFlag |= Math.pow(2, value.index);
                });
                var type = $form.find('input[name="entityType"]').val();
                if (('0' == type && (parseInt($form.find('input[name="video.id"]').val(), 10) > 0))
                    // 如果是节目且专辑id禁用表示编目修改
                    || ('1' === type && (parseInt($form.find('input[name="album.id"]').val(), 10) > 0))
                    // 如果是专辑有#_entityId表示修改
                    || ($form.find('input[name=pilosityType]').val() && $form.find('input[name=baseId]').val())
                    // 如果是一文多发有pilosity且有baseId表示修改
                ) {
                    // 节目，专辑, 一文多发，兼容旧的，修改的时候不验证截图
                    testFlag = 99;
                }
                $croparea.find('input[name="_image_crop_' + useType + '"]').val(testFlag);
                imageObject.push(imageData);
            });
            return JSON.stringify(imageObject);
        };


        getUrlId = function(name) {

            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return r[2];
            return null;
        };

        fillFieldNameWhenChangeSelect = function($form, elClazzName, fieldClazzName) {
            $form.find('.' + elClazzName).on('change', function() {
                var value = $(this).val();
                var $input = $(this).closest('.control-group').find('.' + fieldClazzName);
                $input.attr('name', value);
            });
        };


        /**
         * 限制输入框中字符个数，一个汉字相当于两个字符，wordCount是最多允许的汉字个数
         * @param  {jquery  object}  $des  限制字符个数的输入框
         * @param  {Number}  wordCount     允许输入的最多汉字个数,默认为450个汉字
         * @param  {Boolean} isFilterChars 是否过滤输入内容，true过滤，false或undefined不过滤
         * @param  {Array}  filterChars    需要过滤的字符集，如['$','.']，意为全局过滤 $ *                                 和 .
         */
        var limitWordCount = function($des, wordCount, isFilterChars, filterChars) {
            wordCount = wordCount || 450;
            var t = function(textarea) {
                var $textarea = $(textarea);
                var text = $textarea.val();
                if (isFilterChars) {
                    // text = Com.string.filterSpecialChars(text, filterChars);
                    $textarea.val(text);
                }
                var length = Com.string.getStrLength(text);
                if (length > wordCount * 2) {
                    $textarea.val(Com.string.substrCn(text, wordCount));
                }
                text = $textarea.val();
                length = Com.string.getStrLength(text);
                $textarea.parent().find('span.leftWordsCount').text(wordCount - Math.round(length / 2));
            };
            $des.bind({
                input: function() {
                    t(this);
                },
                propertychange: function() {
                    t(this);
                },
                keyup: function() {
                    t(this);
                }
            });
            $des.keyup();
        };

        var getUploadFiles = function(options, isNew) {
            if (isNew && isNew === true) {
                return new Ancestor.Upload(options);
            }
            if (!uploadFiles) {
                uploadFiles = new Ancestor.Upload(options);
            } else {
                uploadFiles.update(options);
            }
            return uploadFiles;
        };

        var isNormal = function(user) {

            return true;
        };



        // 打开对话框
        var openDlg = function(obj, title, width, height) {

            height = height || 'auto';
            var $container = obj;

            $container.dialog({
                title: title,
                appendTo: null,
                modal: true,
                width: width,
                height: height,
                position: ['top', 'top+20'],

                open: function() {
                    $(".ui-dialog-titlebar-close").html('<span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">close</span>');
                },
                close: function() {

                }
            });
        };

        var highlight = function(data, key, term) {
            data.forEach(function(item, i) {
                key = key || 'label';
                var label = item[key];
                if (!label || !term) {
                    return;
                }
                item[key] = (item[key] + '').replace(new RegExp('(' + term + ')', 'i'), '<b>$1</b>');
                // 高亮未输入部分
                // if (label.toLowerCase().indexOf(term.toLowerCase()) == 0) {
                //     item[key] = item[key].substr(0, term.length)
                //                   + '<b>'
                //                   + item[key].substr(term.length) + '</b>';
                // }
            });
        };

        var updateParamsBySettings = function(params, entity) {
            if (!params) {
                params = {};
            }

            if (entity.checkPublishType == 1) {
                params["filter_EQI_pagePublishStatus"] = 1;
            }
            if (entity.checkCopyRightType == 1) {
                params["filter_GTI_copyrightOwnerId"] = 0;
            }
            if (entity.checkBossType == 0) {
                params["filter_INI_isPurchase"] = "0,-100";
            } else if (entity.checkBossType == 1) {
                params["filter_INI_isPurchase"] = "1,2";
            }
            var platformTypeResponse = Ancestor.Config.PLATFORM_TYPE;
            $.each(platformTypeResponse, function(i, element) {
                //   params["region_" + element.val] = 0;
                if (entity.regionLimitArr.indexOf(parseInt(element.key)) != -1) {
                    params["region_" + element.val] = 1;
                }
            });
            var platformReferResponse = Ancestor.Config.PLATFORM_REFER;
            $.each(platformReferResponse, function(i, element) {
                //   params["filter_EQI_" + element.val] = 0;
                if (entity.onlineLimitArr.indexOf(parseInt(element.key)) != -1) {
                    params["filter_EQI_" + element.val] = 1;
                }

            });
            console.log(" params:" + JSON.stringify(params));

            return params;
        };

        var createSuggest = function(el, options) {
            options = $.extend(true, {
                // 是否自动选择地一条
                autoFocus: true,
                // 选中input时请求
                focusSearch: false,
                sortBy: false,
                // 是否校验结果
                validate: false,
                // 多条时是否验证必有数据
                multipleValid: false,
                // 是否高亮
                highlight: true,
                // 是否onblur时清空无效结果
                clearInvalid: true,
                noResult: '对不起，没有这个结果',
                valueKey: 'id',
                parseValue: function() {
                    var val = this.element.val();
                    var ret = [];
                    if (val) {
                        var items = val.split(';');
                        $.each(items, function(i, item) {
                            item = item.split(',');
                            ret.push({
                                value: item[1],
                                id: item[0],
                                label: item[1]
                            });
                        });
                    }
                    this._value('');
                    return ret;
                },
                create: function(event, ui) {
                    $(this).autocomplete('init');

                    if (options.focusSearch) {
                        $(el).on('focus', function() {
                            if ($.trim(this.value) !== '') {
                                $(this).autocomplete('search');
                            }
                        });
                    }
                },
                otherParam: $.extend({}, options.params),
                source: function(request, response) {
                    var self = this;
                    var term = $.trim(request.term);
                    var result = [];
                    if (!term) {
                        return null;
                    }
                    self.getResultData = function() {
                        return result;
                    };
                    var options = this.options;
                    var dataProcess = options.process || process;
                    var param = {};
                    if (!options.ignoreWord) {
                        //传递 word  term
                        param = {
                            word: term
                        };
                    }
                    param = $.extend(true, options.otherParam, param);

                    //根据dom上定义的sugg-filter过滤项增加过滤参数
                    //sugg-filter中的过滤项以逗号分隔
                    var filterStr = $(el).attr('sugg-filter');
                    if ($.trim(filterStr)) {
                        var filters = $.trim(filterStr).split(',');
                        if (filters && filters.length > 0) {
                            for (var i = 0, l = filters.length, filter; i < l; i++) {
                                filter = filters[i].split('=');
                                if (filter.length == 2) {
                                    param[filter[0]] = filter[1];
                                }
                            }
                        }
                    }

                    var url = options.url;
                    var getParam = options.getParam;
                    if (getParam) {
                        if ($.isFunction(options.getParam)) {
                            param = $.extend(true, param, getParam.call(this, term));
                        } else if ($.isPlainObject(getParam)) {
                            param = $.extend(true, param, getParam);
                        }
                    }

                    var fetchData = function() {
                        Ancestor.Dao.getSuggestData(url, param, function(json) {
                            var ret = dataProcess.call(self, json, term);

                            var runNext = function(ret) {
                                if ($.isArray(options.sortBy)) {
                                    sortBy.apply(self, [ret].concat(options.sortBy));
                                } else if ($.isFunction(options.onSortBy)) {
                                    options.onSortBy.apply(self, [ret, term]);
                                }

                                if (options.highlight) {
                                    if ($.isFunction(options.onHighlight)) {
                                        options.onHighlight.apply(self, [ret, term]);
                                    } else {
                                        highlight(ret, null, term);
                                    }
                                }
                                result = ret;
                                if ($.isFunction(options.onLoad)) {
                                    options.onLoad.apply(self, [result, term]);
                                }
                                response(result);
                            };

                            if (options.needFetchMore) {
                                options.fetchMore(ret, runNext);
                            } else {
                                runNext(ret);
                            }
                        });
                    };

                    if (options.needPreProcess) {
                        var channelId = Com.url.getParameter("id");
                        Ancestor.Dao.platSettings({
                            channelId: channelId
                        }, function(json) {
                            if (json.code === 'A00000') {
                                param = updateParamsBySettings(param, json.data);
                                fetchData();
                            }
                        });
                    } else {
                        fetchData();
                    }


                }
            }, options);

            /* ui-front ui-suggest*/
            return $(el).wrap('<span class="ui-front ui-suggest" ></span>').autocomplete(
                options).on('autocompleteresponse', function(event, ui) {
                var content = ui.content;
                $(this).autocomplete('validate', content);
            }).on('autocompleteselect', function(event, ui) {


                //////////////////suggest选择后回显设置/////////////////////
                //  ui.item.value=ui.item.name;


                return $(this).autocomplete('setValue', ui.item);

            }).on('autocompletesearch', function(event, ui) {
                //支持多选
                return $(this).autocomplete('multiplesearch');
            });
        };

        var qitan = function(el, options) {

            var tpl = '<div><div class="contract-item">' +
                '<span class="contract-width80">${resourceId}</span>' +
                '<span class="contract-width250">{{html name}}</span>' +
                '<span class="contract-width80">${addDate}</span>' +
                '</div></div>';

            var title = {
                resourceId: '评论ID',
                name: '评论名称',
                addDate: '创建时间'
            };

            var getHtmlByData = function(data) {
                var htmls = [];
                var htmlStr = $('<div></div>').html($(tpl).tmpl(data));
                return htmlStr.html();
            };
            var titleHtml = getHtmlByData(title);
            createSuggest(el, $.extend(true, {

                url: 'http://api.t.iqiyi.com/qx_api/resource/get_id_by_name',
                ignoreWord: true,
                header: titleHtml,
                validate: true,
                otherParam: $.extend({
                    'page_size': 10,
                    'resource_type': $(el).data('type') || 1
                }, options.params),
                getParam: function(term) {
                    term = $.trim(term);
                    return {
                        'name': term
                    };
                },
                process: function(json) {
                    if (json.data) {
                        var data = json.data.ids;
                        if (!data) {
                            return [];
                        }
                        var ret = [];
                        $.map(data, function(item) {
                            ret.push($.extend(true, item, {
                                label: item.name,
                                value: item.resourceId,
                                id: item.resourceId
                            }));

                        });
                        return ret;
                    }
                    return [];
                },
                onHighlight: function(data, term) {
                    highlight(data, 'dataName', term);
                },
                template: function(item) {
                    return getHtmlByData(item);
                }
            }, options)).parent().addClass('ui-qitan');
        };


        var universalCodeCreateSuggest = function(el, options) {
            options = $.extend(true, {
                // 是否自动选择地一条
                autoFocus: true,
                // 选中input时请求
                focusSearch: false,
                sortBy: false,
                // 是否校验结果
                validate: false,
                // 多条时是否验证必有数据
                multipleValid: false,
                // 是否高亮
                highlight: true,
                // 是否onblur时清空无效结果
                clearInvalid: true,
                noResult: '对不起，没有这个结果',
                valueKey: 'id',
                parseValue: function() {
                    var val = this.element.val();
                    var ret = [];
                    if (val) {
                        var items = val.split(';');
                        $.each(items, function(i, item) {
                            item = item.split(',');
                            ret.push({
                                value: item[1],
                                id: item[0],
                                label: item[1]
                            });
                        });
                    }
                    this._value('');
                    return ret;
                },
                create: function(event, ui) {
                    $(this).autocomplete('init');

                    if (options.focusSearch) {
                        $(el).on('focus', function() {
                            if ($.trim(this.value) !== '') {
                                $(this).autocomplete('search');
                            }
                        });
                    }
                },
                otherParam: $.extend({}, options.params),
                source: function(request, response) {
                    var self = this;
                    var term = $.trim(request.term);
                    var result = [];
                    if (!term) {
                        return null;
                    }
                    self.getResultData = function() {
                        return result;
                    };
                    var options = this.options;
                    var dataProcess = options.process || process;
                    var param = {};
                    if (!options.ignoreWord) {
                        //传递 word  term
                        param = {
                            word: term
                        };
                    }
                    param = $.extend(true, options.otherParam, param);

                    //根据dom上定义的sugg-filter过滤项增加过滤参数
                    //sugg-filter中的过滤项以逗号分隔
                    var filterStr = $(el).attr('sugg-filter');
                    if ($.trim(filterStr)) {
                        var filters = $.trim(filterStr).split(',');
                        if (filters && filters.length > 0) {
                            for (var i = 0, l = filters.length, filter; i < l; i++) {
                                filter = filters[i].split('=');
                                if (filter.length == 2) {
                                    param[filter[0]] = filter[1];
                                }
                            }
                        }
                    }

                    var url = options.url;
                    var getParam = options.getParam;
                    if (getParam) {
                        if ($.isFunction(options.getParam)) {
                            param = $.extend(true, param, getParam.call(this, term));
                        } else if ($.isPlainObject(getParam)) {
                            param = $.extend(true, param, getParam);
                        }
                    }
                    Ancestor.Dao.getuniversalCodeData(url, param, function(json) {
                        var ret = dataProcess.call(self, json, term);
                        if ($.isArray(options.sortBy)) {
                            sortBy.apply(self, [ret].concat(options.sortBy));
                        } else if ($.isFunction(options.onSortBy)) {
                            options.onSortBy.apply(self, [ret, term]);
                        }

                        if (options.highlight) {
                            if ($.isFunction(options.onHighlight)) {
                                options.onHighlight.apply(self, [ret, term]);
                            } else {
                                highlight(ret, null, term);
                            }
                        }
                        result = ret;
                        if ($.isFunction(options.onLoad)) {
                            options.onLoad.apply(self, [result, term]);
                        }
                        response(result);
                    });

                }
            }, options);

            /* ui-front ui-suggest*/
            return $(el).wrap('<span class="ui-front ui-suggest" ></span>').autocomplete(
                options).on('autocompleteresponse', function(event, ui) {
                var content = ui.content;
                $(this).autocomplete('validate', content);
            }).on('autocompleteselect', function(event, ui) {
                ui.item.value = ui.item.code;
                return $(this).autocomplete('setValue', ui.item);

            }).on('autocompletesearch', function(event, ui) {
                //支持多选
                return $(this).autocomplete('multiplesearch');
            });
        }

        var universalCode = function(el, options) {

            var tpl = '<div><div class="contract-item">' +
                '<span class="contract-width250">${code}</span>' +
                '<span style="border-right:none;">${name}</span>' +
                '</div></div>';

            var title = {
                code: '直播频道首拼音',
                name: '直播频道名称',
            };

            var getHtmlByData = function(data) {
                var htmls = [];
                var htmlStr = $('<div></div>').html($(tpl).tmpl(data));
                return htmlStr.html();
            };
            var titleHtml = getHtmlByData(title);

            universalCodeCreateSuggest(el, $.extend(true, {

                url: '/api/channel/codelist',
                ignoreWord: true,
                header: titleHtml,
                validate: true,
                getParam: function(term) {
                    term = $.trim(term);
                    return {
                        'key': term
                    };
                },
                process: function(json) {
                    if (json.data) {
                        var data = json.data
                        if (!data) {
                            return [];
                        }
                        var ret = [];
                        $.map(data, function(item) {
                            ret.push($.extend(true, item, {
                                name: item.name,
                                code: item.code,
                            }));

                        });
                        return ret;
                    }
                    return [];
                },
                onHighlight: function(data, term) {
                    highlight(data, 'dataName', term);
                },
                template: function(item) {
                    return getHtmlByData(item);
                }
            }, options)).parent().addClass('ui-qitan');
        };



        var qitanSuggest = function($inputs, options) {

            $inputs.each(function(index, element) {
                var self = this;
                qitan($(this), $.extend(true, {
                    validate: false,
                    select: function(e, data) {
                        $(self).parent().parent().find('span.hasConnectQitan').show();
                        var $input = $(e.currentTarget);
                        $input.data('value', data.item.id);
                        //console.log( $input.data('value'));
                    },
                    onNoResult: function() {
                        $(self).parent().parent().find('span.hasConnectQitan').hide();
                    },
                    change: function(event, ui) {
                        if (null === ui.item) {
                            $(self).parent().parent().find('span.hasConnectQitan').hide();
                        }
                    }
                }, options));
            });
        };

        var universalCodeSuggest = function($inputs, options) {

            $inputs.each(function(index, element) {
                var self = this;
                universalCode($(this), $.extend(true, {
                    validate: false,
                    select: function(e, data) {
                        $(self).parent().parent().find('span.hasConnectQitan').show();
                        var $input = $(e.currentTarget);
                        $input.data('value', data.item.code);
                        //console.log($input.data('value'));
                    },
                    onNoResult: function() {
                        $(self).parent().parent().find('span.hasConnectQitan').hide();
                    },
                    change: function(event, ui) {
                        if (null === ui.item) {
                            $(self).parent().parent().find('span.hasConnectQitan').hide();
                        }
                    }
                }, options));
            });
        };



        var alternatePlayCollection = function(el, options) {

            var tpl = '<div class="contract-item">' +
                '<span class="contract-width100" style="color:${needAlert}">${qipuId}</span>' +
                '<span class="contract-width150" style="color:${needAlert}">${displayName}</span>' +
                '<span class="contract-width60" style="color:${needAlert}">${channelName}</span>' +
                '<span class="contract-width120" style="color:${needAlert}">${copyrightEndTime}</span>' +
                '<span class="contract-width80" style="color:${needAlert}">${isPurchase}</span>' +
                '<span class="contract-width80" style="color:${needAlert}">${pagePublishStatus}</span>' +
                '</div>';

            var _ppsClientArr = [
                "ANDRIOD_PPSControl",
                "ANDROID_PAD_PPSControl",
                "IOS_JAILBREAK_PPSControl",
                "IPAD_PPSControl",
                "IPHONE_PPSControl",
                "MAC_PPSControl",
                "PC_CLIENT_PPSControl",
                "WIN8_PPSControl",
                "WINDOWS_PHONE_PPSControl"
            ];

            var _platClientArr = [
                "ANDRIOD_PPS",
                "ANDROID_PAD_PPS",
                "IOS_JAILBREAK_PPS",
                "IPAD_PPS",
                "IPHONE_PPS",
                "MAC_PPS",
                "PC_CLIENT_PPS",
                "WIN8_PPS",
                "WINDOWS_PHONE_PPS"
            ];

            var platformRefer = "platformRefer",
                platSettings = "platSettings",
                platforms = "platforms";

            var title = {
                qipuId: '奇谱ID',
                displayName: '显示名称',
                channelName: '频道',
                copyrightEndTime: '版权到期时间',
                isPurchase: '是否付费',
                pagePublishStatus: '发布状态'
            };

            var checkPlatforms = [];
            Ancestor.Dao.getType({
                type: 'PlayPlatform'
            }, function(json) {
                if (json.code == 'A00000') {
                    Ancestor.Config.PLATFORM_TYPE = json.data;
                    checkPlatforms = json.data;
                } else {
                    console.log('Fetch PlayPlatform failed');
                }
            });


            Ancestor.Dao.getType({
                type: 'PlatformRefer'
            }, function(json) {
                if (json.code == 'A00000') {
                    Ancestor.Config.PLATFORM_REFER = json.data;
                } else {
                    console.log('Fetch PlayPlatform failed');
                }
            });

            var decodePlayPlatform = function(elementChild) {
                var locationControl = null;
                var platformObject = {
                    platName: null,
                    locationArr: []
                }
                platformObject.platName = elementChild["play_platform"];
                platformObject.status = 'online';
                if (elementChild["default_control"] != null) {
                    if ("ONLINE" != elementChild["default_control"]["availabe_status"]) {
                        platformObject.status = "offline";
                    }
                }
                if ($.isArray(elementChild["region_control"])) {
                    $.each(elementChild["region_control"], function(indexRegion, regionElement) {
                        if ($.isArray(regionElement["location"])) {
                            $.each(regionElement["location"], function(j, child) {
                                if(child.hasOwnProperty("province_id")){
                                    if (child["province_id"] != 95 && child["province_id"]  != 148 && child["province_id"]  != 228) {
                                        locationControl = regionElement["location_control"];
                                        if (locationControl != null && "ONLINE" != locationControl["availabe_status"]) {
                                            platformObject.locationArr.push(child["province_id"]);
                                            console.log("break regionElement location");
                                        }
                                    }
                                }
                            })
                        }
                    })
                }
                return platformObject;
            };

            var checkPPSClient = function(data) {
                if (data.qipuId == '奇谱ID') {
                    data['needAlert'] = 0;
                    return data;
                }

                var ppsCheckList = [];
                $.each(_ppsClientArr, function(i, ppsKey) {
                    if (!data.hasOwnProperty(ppsKey) || data[ppsKey] == 0) {
                        ppsCheckList.push(ppsKey);
                    }
                });

                if (ppsCheckList.length > 0) {
                    data['needAlert'] = 'red';
                } else {
                    data['needAlert'] = 'black';
                }
                return data;
            };

            var checkQipuData = function(data) {
                var playControlArr = data.QIPUDATA.access_play_control;
                if ($.isArray(playControlArr)) {
                    var temp = {};
                    $.each(playControlArr, function(index, elementChild) {
                        var platformObject = decodePlayPlatform(elementChild);
                        if (platformObject.platName != null) {
                            temp[platformObject.platName] = platformObject;
                        }
                    });

                    var qipuPlatformData = [];
                    var qipuRegionData = [];
                    var hintMsgObj = {
                        missQIYIClient: false,
                        missPPSClient: false,
                        missQIYIRegion: false,
                        missPPSRegion: false
                    };
                    $.each(checkPlatforms, function(index, element) {
                        var ppsFlag = element.val.indexOf("PPS") !== -1;
                        if (!temp.hasOwnProperty(element.val) || temp[element.val].status != "online") {
                            qipuPlatformData.push(element.val);
                            if (ppsFlag) {
                                hintMsgObj.missPPSClient = true;
                            } else {
                                hintMsgObj.missQIYIClient = true;
                            }
                        }
                        if (temp.hasOwnProperty(element.val) && temp[element.val].locationArr.length > 0) {
                            qipuRegionData.push(element.val);
                            if (ppsFlag) {
                                hintMsgObj.missPPSRegion = true;
                            } else {
                                hintMsgObj.missQIYIRegion = true;
                            }
                        }
                    });

                    if (hintMsgObj.missPPSClient || hintMsgObj.missQIYIClient) {
                        data['needAlert'] = Ancestor.Config.APC_WARNING.RED;
                    } else if (hintMsgObj.missPPSRegion || hintMsgObj.missQIYIRegion) {
                        data['needAlert'] = Ancestor.Config.APC_WARNING.ORANGE;
                    } else {
                        data['needAlert'] = Ancestor.Config.APC_WARNING.NORMAL;
                    }

                }

                return data;
            };

            var getHtmlByData = function(data) {

                if (typeof(data.copyrightEndTime) == "number" || typeof(data.copyrightBeginTime) == "number") {

                    if (data.copyrightEndTime == '-100' || data.copyrightBeginTime == '-100') {
                        data.copyrightEndTime = "永久版权";
                    } else if (new Date() > data.copyrightEndTime || new Date() < data.copyrightBeginTime) {
                        data.copyrightEndTime = "过期";
                    } else {
                        data.copyrightEndTime = Com.date.format(new Date(data.copyrightEndTime), "yyyy-MM-dd hh:mm:ss");
                    }
                }

                //if(data.copyrightEndTime=="过期")
                //  return '';

                switch (data.isPurchase) {
                    case 0:
                    case -100:
                        data.isPurchase = "免费";
                        break;
                    case 1:
                        data.isPurchase = "收费";
                        break;
                    case undefined:
                        data.isPurchase = ""
                        break;

                    default:
                        data.isPurchase = data.isPurchase + ""
                }

                switch (data.pagePublishStatus) {
                    case 0:
                        data.pagePublishStatus = "未发布";
                        break;
                    case 1:
                        data.pagePublishStatus = "已发布";
                        break;
                    case 2:
                        data.pagePublishStatus = "页面下线";
                        break;
                    case 3:
                        data.pagePublishStatus = "页面备用"
                        break;
                    case undefined:
                        data.pagePublishStatus = ""
                        break;

                    default:
                        data.pagePublishStatus = data.pagePublishStatus + "";
                }

                var htmls = [];
                data['needAlert'] = Ancestor.Config.APC_WARNING.NORMAL;

                if (data.hasOwnProperty('QIPUDATA')) {
                    data = checkQipuData(data);
                } else {
                    data = checkPPSClient(data);
                }

                var htmlStr = $('<div></div>').html($(tpl).tmpl(data));

                return htmlStr.html();
            };
            var titleHtml = getHtmlByData(title);
            createSuggest(el, $.extend(true, {

                //url: 'http://lego.iqiyi.com/suggest/simple-video-area',
                url: 'http://lego.iqiyi.com/apis/search/search-area',
                ignoreWord: true,
                header: titleHtml,
                validate: true,
                needFetchMore: true,
                needPreProcess: true,
                otherParam: $.extend({
                    t: 0,
                    filter_GTL_qipuId: 0,
                    //filter_EQI_contentType:1,
                    //'page.orderBy': "createTime",
                    //'page.order': "desc",
                    filter_GEL_duration: 30000,
                    //filter_EQI_pagePublishStatus:1,
                    //filter_INI_isPurchase : "0,-100",
                    //filter_GTI_copyrightOwnerId : 0,
                    //filter_EQI_PadIosControl:1,
                    //filter_EQI_PhoneAndroidControl:1,
                    //filter_EQI_PhoneIosControl:1,
                    //filter_EQI_PcControl:1,
                    //filter_EQI_TvControl:1,
                    //filter_EQI_PcClientControl:1,
                    //filter_EQI_H5Control:1,
                    //filter_EQI_PadAndroidControl:1,
                    //filter_EQI_PadWebControl:1,
                    //region:1,
                    'page.pageSize': 10
                        //                    filter_EQI_ANDRIOD_PPSControl: 1,
                        //                    filter_EQI_ANDROID_PAD_PPSControl: 1,
                        //                    filter_EQI_IOS_JAILBREAK_PPSControl: 1,
                        //                    filter_EQI_IPAD_PPSControl: 1,
                        //                    filter_EQI_IPHONE_PPSControl: 1,
                        //                    filter_EQI_MAC_PPSControl: 1,
                        //                    filter_EQI_PC_CLIENT_PPSControl: 1,
                        //                    filter_EQI_WIN8_PPSControl: 1,
                        //                    filter_EQI_WINDOWS_PHONE_PPSControl: 1,
                        //                    needCookie: true

                    //   pps region 限制
                    //region_ANDROID_PAD_PPS:0,
                    //region_WIN8_PPS:0,
                    //region_MAC_PPS:0,
                    //region_WINDOWS_PHONE_PPS:0,
                    //region_ANDRIOD_PPS:0,
                    //region_IOS_JAILBREAK_PPS:0,
                    //region_IPAD_PPS:0,
                    //region_IPHONE_PPS:0,
                    //region_PC_CLIENT_PPS:0,
                    //   qiyi region 限制
                    //region_ANDROID_PAD_IQIYI:1,
                    //region_ANDROID_PHONE_IQIYI:1,
                    //region_H5_QIYI:1,
                    //region_IOS_PAD_IQIYI:1,
                    //region_IOS_PHONE_IQIYI:1,
                    //region_PAD_WEB_QIYI:1,
                    //region_PC_CLIENT_IQIYI:1,
                    //region_PC_QIYI:1,
                    //region_TV_IQIYI:1,
                }, options.params),
                getParam: function(term) {
                    term = $.trim(term);
                    return {
                        'filter_LIKES_displayName': term
                    };
                },

                fetchMore: function(data, callback) {
                    var self = this;
                    self.count = 0;
                    self.ret = [];
                    self.data = data;
                    $.each(data, function(i, item) {
                        Ancestor.Dao.getQipuDataById(item, function(json, t) {
                            if (json) {
                                t.QIPUDATA = json;
                            }
                            self.ret.push(t);
                            self.count++;
                            if (self.count == self.data.length) {
                                callback(self.ret);
                            }
                        });
                    });
                },
                process: function(json) {
                    if (json.data) {
                        var data = json.data;
                        if (!data) {
                            return [];
                        }
                        var ret = [];
                        $.map(data.result, function(item) {
                            ret.push($.extend(true, item, {
                                name: item.displayName,
                                id: item.qipuId
                            }));

                        });
                        return ret;
                    }
                    return [];
                },
                onHighlight: function(data, term) {
                    highlight(data, 'dataName', term);
                },
                template: function(item) {
                    return getHtmlByData(item);
                }
            }, options)).parent().addClass('ui-backup');
        };

        var alternatePlayCollectionSuggest = function($inputs, options) {
            $inputs.each(function(index, element) {
                var self = this;
                alternatePlayCollection($(this), $.extend(true, {
                    validate: false,
                    select: function(e, data) {
                        $(self).parent().parent().find('span.hasConnectQitan').show();
                        var $input = $(e.currentTarget);
                        $input.data('value', data.item.qipuId);
                        //console.log( $input.data('value'));

                        var temp = data.item;
                        data.item = {};

                        data.item['qipuId'] = temp['qipuId'];
                        data.item['displayName'] = temp['displayName'];
                        data.item['contentType'] = temp['contentType'];
                        data.item['duration'] = temp['duration'];
                        data.item['needAlert'] = temp['needAlert'];
                        temp = {};

                        var alternatePlayCollection = $('input[name="alternatePlayCollection"]').val();
                        //console.log(alternatePlayCollection);
                        if (alternatePlayCollection) {
                            alternatePlayCollection = JSON.parse(alternatePlayCollection);
                            var has = false,
                                i;

                            for (var i in alternatePlayCollection) {
                                if (alternatePlayCollection[i].qipuId == data.item.qipuId) {
                                    has = 1;
                                    break;
                                }
                            }

                            i = parseInt(i) + 1;

                            if (!has) {
                                var msg = null;
                                if (data.item.needAlert == Ancestor.Config.APC_WARNING.RED) {
                                    msg = "该节目【" + data.item.qipuId + " " + data.item.displayName + "】在PPS端没有上线，但会在PPS平台播出，是否确认添加？";
                                } else if (data.item.needAlert == Ancestor.Config.APC_WARNING.ORANGE) {
                                    msg = "该节目【" + data.item.qipuId + " " + data.item.displayName + "】在PPS端有地域播控，但会在PPS平台全地域播出，是否确认添加？";
                                } else {
                                    alternatePlayCollection[i] = data.item;

                                    $('input[name="alternatePlayCollection"]').val(JSON.stringify(alternatePlayCollection));
                                    alternatePlayCollectionAppend({
                                        qipuId: data.item.qipuId
                                    });
                                }

                                if (msg) {
                                    SystemDialog.queryConfirm(msg, function(flag) {
                                        if (flag === true) {
                                            alternatePlayCollection[i] = data.item;

                                            $('input[name="alternatePlayCollection"]').val(JSON.stringify(alternatePlayCollection));

                                            alternatePlayCollectionAppend({
                                                qipuId: data.item.qipuId
                                            });
                                        }
                                    });
                                }
                            }

                        } else {
                            alternatePlayCollection = {};

                            var msg = null;
                            if (data.item.needAlert == Ancestor.Config.APC_WARNING.RED) {
                                msg = "该节目【" + data.item.qipuId + " " + data.item.displayName + "】在PPS端没有上线，但会在PPS平台播出，是否确认添加？";
                            } else if (data.item.needAlert == Ancestor.Config.APC_WARNING.ORANGE) {
                                msg = "该节目【" + data.item.qipuId + " " + data.item.displayName + "】在PPS端有地域播控，但会在PPS平台全地域播出，是否确认添加？";
                            } else {
                                alternatePlayCollection[0] = data.item;

                                $('input[name="alternatePlayCollection"]').val(JSON.stringify(alternatePlayCollection));
                                alternatePlayCollectionAppend({
                                    qipuId: data.item.qipuId
                                });
                            }

                            if (msg) {
                                SystemDialog.queryConfirm(msg, function(flag) {
                                    if (flag === true) {
                                        alternatePlayCollection[0] = data.item;

                                        $('input[name="alternatePlayCollection"]').val(JSON.stringify(alternatePlayCollection));

                                        alternatePlayCollectionAppend({
                                            qipuId: data.item.qipuId
                                        });
                                    }
                                });
                            }
                        }
                    },
                    onNoResult: function() {
                        $(self).parent().parent().find('span.hasConnectQitan').hide();
                    },
                    change: function(event, ui) {
                        if (null === ui.item) {
                            $(self).parent().parent().find('span.hasConnectQitan').hide();
                        }
                    }
                }, options));
            });
        };


        var alternatePlayCollectionAppend = function(v) {
            $('#alternatePlayCollectionIds').append('<span class="ui-suggest-value tagmanagerTag" data-id="' + v.qipuId + '">' + v.qipuId + '<a class="tagmanagerRemoveTag"  onclick="Ancestor.Util.removeAlternatePlayCollection(this)"  title="Remove" href="javascript:;">x</a></span>');
            $('input[name="alternatePlayCollectionInput"]').attr('disabled','disabled');;
        };

        // 删除备播库
        removeAlternatePlayCollection = function(obj) {

            var alternatePlayCollection = $('input[name="alternatePlayCollection"]').val(),
                AlternatePlayCollectionId = $(obj).parent().attr('data-id'),
                alternatePlayCollectionTmp = {};

            alternatePlayCollectionTmp = alternatePlayCollection = JSON.parse(alternatePlayCollection);

            for (var i in alternatePlayCollectionTmp) {
                if (alternatePlayCollectionTmp[i].qipuId == AlternatePlayCollectionId) {
                    delete alternatePlayCollection[i];
                    break;
                }
            }

            if ($.isEmptyObject(alternatePlayCollection)) {
                $('input[name="alternatePlayCollection"]').val('');
                $('input[name="alternatePlayCollectionInput"]').removeAttr('disabled');;
            } else {
                $('input[name="alternatePlayCollection"]').val(JSON.stringify(alternatePlayCollection));
            }

            $(obj).parent().remove();
        };



        var getAuth = function(str) {

            var auth = {
                    'sign': '',
                    'clientTime': '',
                    'from': ''
                },
                time = parseInt(new Date().getTime() / 1000);

            auth.from = Ancestor.Config.EPG_AUTH.From;
            auth.clientTime = time;
            auth.sign = md5(str + time + Ancestor.Config.EPG_AUTH.key);

            //console.log(auth);            
            return auth;

        };

        return {
            imageCrop: imageCrop,
            authorization: authorization,
            getParam: getParam,
            getUrlId: getUrlId,
            fillFieldNameWhenChangeSelect: fillFieldNameWhenChangeSelect,
            limitWordCount: limitWordCount,
            getUploadFiles: getUploadFiles,
            isNormal: isNormal,
            openDlg: openDlg,
            qitanSuggest: qitanSuggest,
            universalCodeSuggest: universalCodeSuggest,
            imageObjectEcho: imageObjectEcho,
            getAuth: getAuth,
            alternatePlayCollectionSuggest: alternatePlayCollectionSuggest,
            alternatePlayCollectionAppend: alternatePlayCollectionAppend,
            removeAlternatePlayCollection: removeAlternatePlayCollection,
        };


    })();

});

define(
    '../epg2/EpgWeb',['require','exports','module'],function(require, exports, module) {
        window.EpgWeb = window.EpgWeb || {
            version: '1.0'
        };

        EpgWeb.Constant = {
            //baseApiUrl:"http://test.admin.epg.qiyi.domain/api/",
            baseApiUrl: "/api/",
            thirdUrl_audit_people: "http://lego.iqiyi.com/suggest/audit-people",
            originalUrl: "http://10.23.84.18:8500/",
            third_location_url:"http://lego.iqiyi.com/suggest/region",
            thirdUrl_qitan_url: "http://api.t.iqiyi.com/qx_api/resource/get_id_by_name",
            thirdUrl_add_qitan_url: "http://api.t.iqiyi.com/qx_api/resource/add_resource",
            thirdUrl_video_url: "http://lego.iqiyi.com/suggest/simple-video",
            thirdUrl_album_url: "http://lego.iqiyi.com/suggest/album",
            thirdUrl_playlist_url: "http://lego.iqiyi.com/suggest/playlist",
            thirdUrl_channel_url:"http://lego.iqiyi.com/apis/channel/list",
            thirdUrl_video_area_url: "http://lego.iqiyi.com/suggest/simple-video-area",
            thirdUrl_album_area_url: "http://lego.iqiyi.com/suggest/album-area",
            thirdUrl_apis_search_area_url: "http://lego.iqiyi.com/apis/search/search-area",
            thirdUrl_category_first_list_url:"http://lego.iqiyi.com/apis/category/live-first-list",
            // use for child secLv thirdLv
            thirdUrl_category_child_list_url: "http://lego.iqiyi.com/category/list",
            thirdUrl_passport_url:"http://passport.qiyi.domain/apis/internal/user_info.action",
            devMode: auth.dev()
        }
        EpgWeb.urlConfig = (function () {
            var useUrl = EpgWeb.Constant.baseApiUrl;
            var programListUrl = useUrl + "program/list";
            var programListSortUrl = useUrl + "program/listSort";
            var programAddUrl = useUrl + "program/add";
            var programDelUrl = useUrl + "program/delete";
            var programEditUrl = useUrl + "program/edit";
            var programLogUrl = useUrl + "program/loglist";
            var configsUrl = useUrl + "configs";
            var channelListUrl = useUrl + "channel/list";
            var programSyncUrl = useUrl + "program/syncTVMao";
            var redirectUrl = useUrl + "redirect";
            var channelGetUrl = useUrl + "channel/get";
            var queryPuYuUrl = useUrl + "program/queryPuYu";
            var carouselRuleListUrl = useUrl + "carousel/get";
            var carouselRuleDelUrl = useUrl + "carousel/del";
            var carouselRuldAddUrl = useUrl + "carousel/create";
            var programLiveQueryUrl = useUrl + "program/liveQuery";
            var programMoveUrl = useUrl + "program/move";
            var programToggleLockUrl = useUrl + "program/toggleLock";
            var programBatchAddUrl = useUrl + "program/batchAdd";
            var carouselEpisodeBatchAddUrl = useUrl + "carousel/carouselEpisode/batchAdd";
            var carouselEpisodeBatchDelUrl= useUrl + "carousel/carouselEpisode/batchDel";
            var carouselEpisodeListUrl= useUrl + "carousel/carouselEpisode/list";
            var carouselEpisodeIndexMoveUrl= useUrl + "carousel/carouselEpisode/indexMove";
            var carouselEpisodeIndexMoveByIndexUrl= useUrl + "carousel/carouselEpisode/indexMove/byIndex";
            var programDaySortUrl = useUrl + "program/daySort";
            var programIndexMoveUrl = useUrl + "program/indexMove";
            var programBatchDelUrl = useUrl + "program/batchDel";
            var platSettingsGetUrl = useUrl + "channel/getPlatSettings";
            var yesterdayEndTimeUrl = useUrl + "program/yesterdayEndTime";
            var automationAddUrl = useUrl + "carousel/automation/add";
            var automationDelUrl = useUrl + "carousel/automation/del";
            var automationListUrl = useUrl + "carousel/automations";
            var automationMoveUrl = useUrl + "carousel/automation/indexMove";
            var automationMoveByIndexUrl = useUrl + "carousel/automation/indexMove/byIndex";
            var automationChangeStatusUrl = useUrl + "carousel/automation/changeStatus";
            var getBroadcastControlsUrl = useUrl+"broadcast/controls";
            var reservation_create_Url = useUrl+ "reservation";
            var reservation_del_Url = useUrl+ "reservation/del";
            var reservation_edit_Url = useUrl+"reservation/edit";
            var reservation_get_Url = useUrl+ "reservations";
            var setBroadcastControlAllUrl= useUrl+"broadcast/controlall";
            var setBroadcastControlUrl  = useUrl+"broadcast/control";
            var platSettingsSaveUrl =  useUrl+"channel/savePlatSettings";
            var programBroadcastControlUrl =  useUrl+"program/broadcast/control";
            var programForceCheckUrl = useUrl + "program/forceCheck";
            var advertModifyUrl  = useUrl + "advert/modify";
            var directorCreateUrl =  useUrl + "director/create";
            var notifyAlertUrl = useUrl + "notify/alertPlatform";
            function getQiPuBaseUrl(qipuId){
                var plusUrl = EpgWeb.Constant.devMode ? "http://qipu-test.qiyi.domain/int/entity/nocache/@.json" : "http://qipu.qiyi.domain/int/entity/nocache/@.json";
                return plusUrl.replace("@", "" + qipuId);
            }
            return {
                programList: programListUrl,
                programListSortUrl: programListSortUrl,
                programAdd: programAddUrl,
                programDel: programDelUrl,
                programEdit: programEditUrl,
                programLog:programLogUrl,
                programForceCheck:programForceCheckUrl,
                configs: configsUrl,
                channelList: channelListUrl,
                channelGet: channelGetUrl,
                programSyncUrl: programSyncUrl,
                queryPuYu: queryPuYuUrl,
                carouselRuleListUrl: carouselRuleListUrl,
                carouselRuleDelUrl: carouselRuleDelUrl,
                carouselRuldAddUrl: carouselRuldAddUrl,
                carouselEpisodeBatchAddUrl:carouselEpisodeBatchAddUrl,
                carouselEpisodeBatchDelUrl:carouselEpisodeBatchDelUrl,
                carouselEpisodeListUrl:carouselEpisodeListUrl,
                carouselEpisodeIndexMoveUrl:carouselEpisodeIndexMoveUrl,
                carouselEpisodeIndexMoveByIndexUrl:carouselEpisodeIndexMoveByIndexUrl,
                programLiveQueryUrl: programLiveQueryUrl,
                programMoveUrl: programMoveUrl,
                programToggleLockUrl: programToggleLockUrl,
                programDaySortUrl: programDaySortUrl,
                programBatchAddUrl: programBatchAddUrl,
                programIndexMoveUrl: programIndexMoveUrl,
                programBatchDelUrl: programBatchDelUrl,
                platSettingsGetUrl: platSettingsGetUrl,
                yesterdayEndTimeUrl: yesterdayEndTimeUrl,
                automationAddUrl: automationAddUrl,
                automationDelUrl: automationDelUrl,
                automationListUrl: automationListUrl,
                automationMoveUrl: automationMoveUrl,
                automationChangeStatusUrl: automationChangeStatusUrl,
                reservationCreate:reservation_create_Url,
                reservationDel:reservation_del_Url,
                reservationGet:reservation_get_Url,
                getBroadcastControls:getBroadcastControlsUrl,
                reservationEdit:reservation_edit_Url,
                setBroadcastControlAllUrl:setBroadcastControlAllUrl,
                setBroadcastControl:setBroadcastControlUrl,
                platSettingsSaveUrl:platSettingsSaveUrl,
                programBroadcastControlUrl:programBroadcastControlUrl,
                redirect: redirectUrl,
                advertModifyUrl:advertModifyUrl,
                directorCreateUrl:directorCreateUrl,
                notifyAlertUrl:notifyAlertUrl,
                getQiPuBaseUrl:getQiPuBaseUrl
            }
        })();

        EpgWeb.ajaxQueue = (function () {
            var entity = this;
            var taskArr = [];
            var batchArr = [];
            var timerId = -1;
            var errorCollectArr = [];
            var afterCompleteArr = [];
            var status = -2;
            var checkComplete = function () {
                switch (status) {
                    case 1:
                        clearInterval(timerId);
                        timerId = -1
                        if (errorCollectArr.length > 0) {
                            var totalError = errorCollectArr.join("\n");
                            errorCollectArr = [];
                            EpgWeb.Plugin.showTips({
                                content: totalError,
                                type: "error"
                            })
                        }
                        status = 2;
                        loadComplete();
                        batchComplete();
                        break;
                    case -1:
                        $.each(taskArr, function (index, obj) {
                            if (obj.responseData == null) {
                                var ajaxData = obj.ajaxData;
                                $.ajax({
                                    type: ajaxData.type,
                                    url: ajaxData.url,
                                    dataType: ajaxData.dataType,
                                    beforeSend: function (request) {
                                        request.setRequestHeader("Sign", "#f93Uc31K24()_@");
                                    },
                                    data: ajaxData.data,
                                    success: function (data) {
                                        var tempTarget = findTaskByRegName(obj.regName);
                                        if (tempTarget.needRemove == true) {
                                            removeTask(obj.regName);
                                        } else {
                                            tempTarget.responseData = data;
                                        }
                                        if (ajaxData.success != null) {
                                            ajaxData.success(data);
                                        }
                                    },
                                    error: function (data) {
                                        if (ajaxData.error != null) {
                                            ajaxData.error(data);
                                        }
                                        errorCollectArr.push(obj.regName + " 请求失败")
                                        removeTask(obj.regName)
                                    }
                                });
                            }
                        })
                        status = 0;
                        timerId = setInterval(checkComplete, 16);
                        break;
                    case 0:
                        var allComplete = true;
                        $.each(taskArr, function (index, obj) {
                            if (obj.responseData == null) {
                                allComplete = false;
                                return true;
                            }
                        });
                        if (allComplete) {
                            status = 1;
                        }
                        break;
                }
            }

            var batchComplete = function () {
                var tempArr = batchArr;
                batchArr =[];
                while (tempArr.length > 0) {
                    var batchRequestData = tempArr.pop();
                    batchRequestData.handler({"originalArr": batchRequestData.originalArr,
                            "acceptArr": batchRequestData.acceptMsgArr}
                    );
                }
            }

            var loadComplete = function () {
                console.log("loadComplete over");
                var tempArr = afterCompleteArr;
                afterCompleteArr = [];
                while (tempArr.length > 0) {
                    var excuteFunc = tempArr.shift();
                    excuteFunc.call();
                }
            }

            var push = function (regName, ajaxData, responseData, needRemove){
                if (typeof(needRemove) != "boolean") {
                    needRemove = needRemove == null ? false : true
                }
                taskArr.push({"regName": regName, "ajaxData": ajaxData, "responseData": responseData, "needRemove": needRemove})
            }

            var batchRequest = function (regName, ajaxData, sendDataArr, handler){
                var acceptMsgArr = [];
                var batchRequestData = {"originalArr": sendDataArr, "acceptMsgArr": acceptMsgArr, handler: handler }
                batchArr.push(batchRequestData)
                $.each(sendDataArr, function (index, obj) {
                    taskArr.push(
                        {
                            "regName": regName + "_" + index,
                            "ajaxData": {
                                type: ajaxData.type,
                                url: ajaxData.url,
                                dataType: ajaxData.dataType,
                                data: obj,
                                success: function (data) {
                                    var formatData = null;
                                    if (data != null) {
                                        formatData = {"nodeIndex": index, "operationSuccess": false, "responseData": data, "msg": data.msg};
                                        if (data.code == "A00000") {
                                            formatData.operationSuccess = true;
                                        }
                                    } else {
                                        formatData = {"nodeIndex": index, "error": true, "operationSuccess": false, "responseData": data};
                                    }
                                    acceptMsgArr.push(formatData)
                                },
                                error: function (data) {
                                    var formatData = {"nodeIndex": index, "error": true, "operationSuccess": false, "responseData": data};
                                    acceptMsgArr.push(formatData);
                                }
                            },
                            "needRemove": true
                        });
                })
            }

            var startLoad = function(){
                if (status != -2 && status != 2) {
                    return false;
                }
                status = -1;
                console.log(JSON.stringify(taskArr) );
                checkComplete();
                return true;
            }

            var findResponseData = function (regName) {
                var task = findTaskByRegName(regName);
                if (task == null) {
                    return null;
                }
                return task.responseData;
            }
            var removeTask = function (regName) {
                var task = findTaskByRegName(regName);
                if (task != null) {
                    var taskIndex = taskArr.indexOf(task)
                    taskArr.splice(taskIndex, 1);
                }
            }

            var findTaskByRegName = function(regName) {
                if (taskArr.length == 0) {
                    return null;
                }
                var returnTarget = null;
                $.each(taskArr, function (index, obj) {
                    if (obj.regName == regName) {
                        returnTarget = obj;
                        return false;
                    }
                })
                return returnTarget;
            }

            var afterLoadComplete = function (callback) {
                if (typeof(callback) == "function") {
                    afterCompleteArr.push(callback);
                }
            }

            var isRunning = function () {
                return status == 0;
            }

            function getTaskArr(){
                return [].concat(taskArr);
            }

            function getStatus(){
                return status;
            }

            return {
                startLoad:startLoad,
                findResponseData:findResponseData,
                findTaskByRegName:findTaskByRegName,
                batchRequest:batchRequest,
                push:push,
                isRunning:isRunning,
                removeTask:removeTask,
                afterLoadComplete:afterLoadComplete,
                getTaskArr:getTaskArr,
                getStatus:getStatus
            }
        })();
    }
);
define(
    '../epg2/EpgWeb.Util',['require','exports','module'],function (require, exports, module) {
        EpgWeb.Util = $.extend(true, {}, Ancestor.Util, {
            tranDurationFormat: function (duration) {
                var darArr = [];
                darArr.push(duration % 60);
                duration = ( duration - duration % 60) / 60;
                if (duration > 0) {
                    darArr.push(duration % 60);
                }
                duration = ( duration - duration % 60) / 60;
                if (duration > 0) {
                    darArr.push(duration % 24);
                }
                duration = ( duration - duration % 24) / 24;
                if (duration > 0) {
                    darArr.push(duration);
                }
                var retValue = "";
                switch (darArr.length) {
                    case 4:
                        retValue = darArr[3] + "天";
                    case 3:
                        retValue += darArr[2] + "时";
                    case 2:
                        retValue += darArr[1] + "分";
                    case 1:
                        retValue += darArr[0] + "秒";
                        break;
                }
                return retValue;
            },
            makeUpRedirect: function (url, method, params, needCookie) {
                var requestData = {url: url, type: method, params: params};
                if (needCookie === true) {
                    requestData.needCookie = true;
                }
                return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
            },
            quickDateFormat: function (startTime) {
                return startTime.getFullYear() + "-" +
                    (startTime.getMonth() < 9 ? "0" + (startTime.getMonth() + 1) : (startTime.getMonth() + 1) ) + "-" +
                    (startTime.getDate() < 10 ? "0" + startTime.getDate() : startTime.getDate() );
            },
            bindDateMax: function (name1, name2, plusData) {
                $("input[name=" + name1 + "]").datetimepicker({
                    sliderAccessArgs: { touchonly: false },
                    onClose: function (selectedDate) {
                        $("input[name=" + name2 + "]").datetimepicker("option", "maxDate", selectedDate);
                        var toDate = new Date(selectedDate.replace(/-/g, "/"))
                        $("input[name=" + name2 + "]").datetimepicker("option", "maxDateTime", toDate);
                    }
                })
                if (plusData != null) {
                    $("input[name=" + name1 + "]").datetimepicker("option", "minDate", plusData.minDate);
                    $("input[name=" + name1 + "]").datetimepicker("option", "minDateTime", plusData.minDateTime);
                }
            },
            setZeroTime: function (checkTime) {
                checkTime.setSeconds(0);
                checkTime.setMinutes(0);
                checkTime.setHours(0);
                checkTime.setMilliseconds(0);
            },
            setDayLastTime: function (checkTime) {
                checkTime.setSeconds(59);
                checkTime.setMinutes(59);
                checkTime.setHours(23);
                checkTime.setMilliseconds(0);
            },

            bindDate: function (nameMin, nameMax, plusData) {
                var options1 = {
                    sliderAccessArgs: { touchonly: false },
                    onClose: function (selectedDate) {
                        console.log("bindDate " +  selectedDate )
                        $("input[name=" + nameMax + "]").datetimepicker("option", "minDate", selectedDate);
                        var toDate = new Date(selectedDate.replace(/-/g, "/"))
                        $("input[name=" + nameMax + "]").datetimepicker("option", "minDateTime", toDate);
                    }
                }
                var options2 = {
                    sliderAccessArgs: { touchonly: false },
                    onClose: function (selectedDate) {
                        console.log("bindDate " +  selectedDate )
                        $("input[name=" + nameMin + "]").datetimepicker("option", "maxDate", selectedDate);
                        var toDate = new Date(selectedDate.replace(/-/g, "/"))
                        $("input[name=" + nameMin + "]").datetimepicker("option", "maxDateTime", toDate);
                    }
                }
                if (plusData != null && plusData.hasOwnProperty("slider")) {
                    options1.controlType = "slider";
                    options2.controlType = "slider";
                }
                $("input[name=" + nameMin + "]").datetimepicker(options1)
                $("input[name=" + nameMax + "]").datetimepicker(options2)
                if (plusData != null) {
                    $("input[name=" + nameMin + "]").datetimepicker("option", "maxDate", plusData.maxDate);
                    $("input[name=" + nameMin + "]").datetimepicker("option", "maxDateTime", plusData.maxDateTime);
                    $("input[name=" + nameMax + "]").datetimepicker("option", "minDate", plusData.minDate);
                    $("input[name=" + nameMax + "]").datetimepicker("option", "minDateTime", plusData.minDateTime);
                }
            },



            bindDateMin: function (name1, name2, plusData) {
                $("input[name=" + name1 + "]").datetimepicker({
                    sliderAccessArgs: { touchonly: false },
                    onClose: function (selectedDate) {
                        $("input[name=" + name2 + "]").datetimepicker("option", "minDate", selectedDate);
                        var toDate = new Date(selectedDate.replace(/-/g, "/"))
                        $("input[name=" + name2 + "]").datetimepicker("option", "minDateTime", toDate);
                    }
                })
                if (plusData != null) {
                    $("input[name=" + name1 + "]").datetimepicker("option", "maxDate", plusData.maxDate);
                    $("input[name=" + name1 + "]").datetimepicker("option", "maxDateTime", plusData.maxDateTime);
                }
            },
            createPageBean: function () {
                return (function () {
                    var source = [];
                    var dataLength = source.length;
                    var rowNum = 10;
                    var total = (dataLength % rowNum == 0 ? 0 : 1) + parseInt(dataLength / rowNum);
                    var cur = 1;

                    function goToFirst() {
                        return goToUser(1);
                    }

                    function goToLast() {
                        return goToUser(total);
                    }

                    function goToUser(toPage) {
                        if (toPage < 1) toPage = 1;
                        if (toPage > total) toPage = total;
                        cur = toPage;
                        var end = cur * rowNum > dataLength ? dataLength : cur * rowNum;
                        var showData = source.slice((cur - 1) * rowNum, end);
                        return {"total": total, "page": cur, "records": dataLength, "rows": showData};
                    }

                    function getCur() {
                        return goToUser(cur);
                    }

                    function goNext() {
                        return goToUser(cur + 1);
                    }

                    function goPrev() {
                        return goToUser(cur - 1);
                    }

                    function setNewData(newData, newRowNum) {
                        source = newData == null ? [] : newData;
                        if (newRowNum != null && newRowNum > 0) {
                            rowNum = newRowNum;
                        }
                        dataLength = source.length;
                        total = (dataLength % rowNum == 0 ? 0 : 1) + parseInt(dataLength / rowNum);
                    }

                    function addNewOne(newOne) {
                        source.push(newOne);
                        setNewData(source, rowNum);
                    }

                    function delOne(delOne) {
                        var targetIndex = source.indexOf(delOne);
                        if (targetIndex > -1) {
                            source.splice(targetIndex, 1);
                            setNewData(source, rowNum);
                        }
                    }

                    function getSource() {
                        return [].concat(source);
                    }

                    function findData(keyName, value) {
                        var ret = null;
                        if (value == null || keyName == null) {
                            return null;
                        }
                        $.each(source, function (i, element) {
                            if (element != null && element[keyName] == value) {
                                ret = element;
                                return true;
                            }
                        })
                        return ret;
                    }

                    function sortData(func) {
                        if (typeof( func ) == "function") {
                            source.sort(func);
                        }
                    }

                    return {
                        goToFirst: goToFirst,
                        goToLast: goToLast,
                        goToUser: goToUser,
                        goNext: goNext,
                        goPrev: goPrev,
                        getCur: getCur,
                        setNewData: setNewData,
                        addNewOne: addNewOne,
                        delOne: delOne,
                        getSource: getSource,
                        findData: findData,
                        sortData: sortData
                    }
                })()
            },
            pageBeanPageHandler: function (gridId, pageId, pageBean, pgButton) {
                var retValue = null;
                switch (pgButton) {
                    case "next_" + pageId:
                        retValue = pageBean.goNext()
                        break;
                    case "prev_" + pageId:
                        retValue = pageBean.goPrev()
                        break;
                    case "last_" + pageId:
                        retValue = pageBean.goToLast()
                        break;
                    case "user":
                        retValue = pageBean.goToUser(parseInt($("#gbox_" + gridId + " .ui-pg-input").val()));
                        break;
                    case "first_" + pageId:
                        retValue = pageBean.goToFirst();
                        break;
                }
                return retValue
            },
            transGetParams: function (params) {
                var str = "";
                for (var key in params) {
                    str += key + "=" + params[key] + "&";
                }
                if (str.length > 0) {
                    str = str.substr(0, str.length - 1);
                }
                return str;
            },

            formatDateTimeFormat: function (myDate) {
                var year = myDate.getFullYear();
                var month = ("0" + (myDate.getMonth() + 1)).slice(-2);
                var day = ("0" + myDate.getDate()).slice(-2);
                var h = ("0" + myDate.getHours()).slice(-2);
                var m = ("0" + myDate.getMinutes()).slice(-2);
                var s = ("0" + myDate.getSeconds()).slice(-2);
                return year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s;
            },
            getQueryComponent: function (handlerObj) {
                return {
                    source: null,
                    total: 0,
                    completeNum: 0,
                    handlerObj: handlerObj,
                    doInit: function (newArr) {
                        var self = this;
                        self.source = newArr;
                        self.total = newArr.length;
                        self.completeNum = 0;
                        self.doSubmit();
                    },
                    doSubmit: function () {
                        var self = this;
                        self.doBefore();
                        $.each(self.source, function (i, element) {
                            self.doSingle(element, function () {
                                self.notifyHandler()
                            });
                        })
                    },
                    doBefore: function () {
                        var self = this;
                        if (self.handlerObj != null) {
                            if (self.handlerObj.hasOwnProperty("doBefore")) {
                                self.handlerObj.doBefore();
                            }
                        }
                    },
                    doAfter: function () {
                        var self = this;
                        if (self.handlerObj != null) {
                            if (self.handlerObj.hasOwnProperty("doAfter")) {
                                self.handlerObj.doAfter();
                            }
                        }
                    },
                    doSingle: function (element, notifyHandler) {
                        var self = this;
                        if (self.handlerObj != null) {
                            if (self.handlerObj.hasOwnProperty("doSingle")) {
                                self.handlerObj.doSingle(element, notifyHandler);
                            }
                        }
                    },
                    notifyHandler: function () {
                        var self = this;
                        self.completeNum++;
                        if (self.completeNum == self.total) {
                            self.doAfter();
                        }
                    }
                };
            },
            createWeekManager: function (labelArr) {
                return (function ($labelArr) {
                    var focusStartTime = null;
                    var selectDateTime = null;
                    var weekday = "星期日,星期一,星期二,星期三,星期四,星期五,星期六".split(",");

                    function preWeek() {
                        if (focusStartTime != null) {
                            updateWeek(new Date(focusStartTime.getTime() - 7 * 86400 * 1000));
                        }
                    }

                    function nextWeek() {
                        if (focusStartTime != null) {
                            updateWeek(new Date(focusStartTime.getTime() + 7 * 86400 * 1000));
                        }
                    }

                    function updateWeek(startTime) {
                        if (startTime != null) {
                            focusStartTime = startTime;
                        }
                        var tempStartTime = new Date(focusStartTime.getTime());
                        $labelArr.each(function (i, element) {
                            var lDateFormat = EpgWeb.Util.quickDateFormat(tempStartTime);
                            $(element).attr("query-date", lDateFormat);
                            $(element).removeClass("selected");
                            $(element).html(weekday[tempStartTime.getDay()] + "<br>" + lDateFormat);
                            if (lDateFormat == selectDateTime) {
                                $(element).addClass("selected");
                            }
                            tempStartTime.setTime(tempStartTime.getTime() + 86400 * 1000);
                        })
                    }

                    function quickToCurrentWeek() {
                        var current = new Date();
                        var currentIndex = -1;
                        if (current.getDay() == 0) {
                            currentIndex = 6;
                        } else {
                            currentIndex = current.getDay() - 1;
                        }
                        selectDateTime = EpgWeb.Util.quickDateFormat(current)
                        updateWeek(new Date(current.getTime() - currentIndex * 86400 * 1000));
                        //updateTableByDate(selectDateTime);
                        return selectDateTime;
                    }

                    return{
                        preWeek: preWeek,
                        nextWeek: nextWeek,
                        quickToCurrentWeek: quickToCurrentWeek
                    }
                })(labelArr)
            },
            createHeartBeatUtil: function () {
                return  (function () {
                    var params = {
                        startTime: 0,
                        isStarted: false,
                        indexId: 0,
                        dataArr: []
                    }

                    function doHeartBeat() {
                        var curTime = Date.now();
                        var cpArr = [].concat(params.dataArr);

                        $.each(cpArr, function (i, element) {
                            tick(element, curTime);
                        })
                    }

                    function start() {
                        if (params.isStarted) {
                            console.log("has started");
                            return;
                        }
                        params.startTime = Date.now();
                        params.isStarted = true;
                        $.each(params.dataArr, function (i, elment) {
                            elment.lastTime = params.startTime;
                        })
                        setInterval(function () {
                            doHeartBeat();
                        }, 160)
                    }

                    function tick(element, curTime) {
                        if (element.block || element.stop) {
                            return;
                        }
                        if (element.lastTime + element.gapTime < curTime) {
                            element.lastTime = curTime;
                            element.options.handler();
                            if (element.options.needBlock) {
                                element.block = true;
                            }
                        }
                    }

                    function pushTask(taskObj) {
                        params.indexId++;
                        var taskOptions = {
                            block: false,
                            stop: taskObj.stop || false,
                            options: taskObj,
                            id: params.indexId,
                            lastTime: 0
                        }
                        taskOptions.gapTime = accountGapTime(taskObj)
                        if (params.isStarted) {
                            taskOptions.lastTime = Date.now() + 100;
                        }
                        params.dataArr.push(taskOptions);
                        return taskOptions;
                    }

                    function accountGapTime(taskObj) {
                        var time = [0, 0, 0, 0];//ms,s,m,h
                        if ("ms" in taskObj.gap) {
                            time[0] = taskObj.gap.ms;
                        }
                        if ("s" in taskObj.gap) {
                            time[1] = taskObj.gap.s;
                        }
                        if ("m" in taskObj.gap) {
                            time[2] = taskObj.gap.m;
                        }
                        if ("h" in taskObj.gap) {
                            time[3] = taskObj.gap.h;
                        }
                        return  time[0] + time[1] * 1000 + time[2] * 60000 + time[3] * 3600000;
                    }

                    return {
                        start: start,
                        doHeartBeat: doHeartBeat,
                        pushTask: pushTask,
                        tick: tick
                    }
                })();
            },
            notifyAlert: function (sendData, handler) {
                EpgWeb.Dao.notifyAlert(sendData, function (rdata) {
                    handler(rdata)
                });
            },
            getCurrentUserEntity:function(){
                var ret = null;
                try{
                    ret =auth.baseInfo.authInfo;
                }catch (e){
                    console.warn(e);
                }
                return ret
            }
        });
    }
);
define(
    '../epg2/EpgWeb.Plugin',['require','exports','module'],function (require, exports, module) {
        EpgWeb.Plugin = {
            showTips: function (options) {
                if (!options.hasOwnProperty("type")) {
                    options.type = "success";
                }
                if ($(document).tips != null) {
                    $(document).tips(options)
                }
                if ($(document).tip != null) {
                    $(document).tip(options)
                } else {
                    console.log("no tips plugin " + options);
                }
            },
            Validate: (function () {
                var reg1 = /^\d+$/;
                var reg3 = /^[1-9]\d*$/;
                var reg2 = /^(19|20)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1]) ([0-2][0-9]):([0-5][0-9]):([0-5][0-9])$/;
                var reg4 = /^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/;
//                var _defaultHandler = function(msg){
//                    EpgWeb.Plugin.showTips({type: "error", content: msg})
//                }
                var _bindHandler = null;
                var checkObj = {
                    self_design: function (checkData, checkValue) {
                        return checkData.checkCall(checkData, checkValue)
                    },
                    date: function (checkData, checkValue) {
                        return checkDateFormat(checkValue);
                    },
                    not_empty: function (checkData, checkValue) {
                        return checkValue != null && $.trim(checkValue).length > 0;
                    },
                    eq: function (checkData, checkValue) {
                        return checkValue === checkData.other;
                    },
                    ne: function (checkData, checkValue) {
                        return checkValue !== checkData.other;
                    },
                    ge: function (checkData, checkValue) {
                        return  checkValue >= checkData.other;
                    },
                    gt: function (checkData, checkValue) {
                        return  checkValue > checkData.other;
                    },
                    lt: function (checkData, checkValue) {
                        return checkValue < checkData.other;
                    },
                    le: function (checkData, checkValue) {
                        return checkValue <= checkData.other;
                    },
                    positive:function(checkData, checkValue) {
                        return  checkPositive(checkValue)
                    },
                    number: function (checkData, checkValue) {
                        return checkNum(checkValue);
                    },
                    endsWith: function (checkData, checkValue) {
                        return checkValue != null && typeof(checkValue) == "string" && checkValue.slice(-(checkData.other.length)) == checkData.other;
                    }
                }

                function checkNum(checkString) {
                    return reg1.test(checkString)
                }

                function checkDateFormat(checkString) {
                    return reg2.test(checkString)
                }

                function checkPositive(checkString) {
                    return reg3.test(checkString)
                }

                function defaultHandler(msg) {
                    if(_bindHandler != null){
                        _bindHandler(msg);
                    }
                }

                function batchCheck(checkArr) {
                    if (checkArr == null) {
                        checkArr = [];
                    }
                    if (checkArr.length == 0) {
                        return true;
                    }
                    var flag = false;
                    $.each(checkArr, function (index, checkData) {
                        flag = baseCheck(checkData);
                        if (!flag) {
                            return false;
                        }
                    })
                    return flag;
                }

                function baseCheck(checkData) {
                    var flag = false;
                    //$.isArray(checkData.value )
                    if (!(checkData.value instanceof Array)) {
                        checkData.value = [checkData.value];
                    }
                    //$.isArray(checkData.error )
                    if (!(checkData.error instanceof Array)) {
                        checkData.error = [checkData.error];
                    }
                    if (checkData.handler == null) {
                        checkData.handler = defaultHandler;
                    }
                    $.each(checkData.value, function (index, checkValue) {
                        if (checkObj.hasOwnProperty(checkData.type)) {
                            flag = checkObj[checkData.type](checkData, checkValue);
                        }
                        if (!flag) {
                            var hint = checkData.error.length == checkData.value.length ? checkData.error[index] : checkData.error[0];
                            checkData.handler(hint);
                            return false;
                        }
                    })
                    return flag
                }
                function bindDefaultHandler(func){
                    _bindHandler = func;
                }
                return {
                    baseCheck: baseCheck,
                    batchCheck: batchCheck,
                    checkDateFormat: checkDateFormat,
                    checkNum: checkNum,
                    bindDefaultHandler:bindDefaultHandler
                }
            })(),

            tableToExcel: (function () {
                var uri = 'data:application/vnd.ms-excel;base64,',
                    template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
                    base64 = function (s) {
                        return window.btoa(unescape(encodeURIComponent(s)))
                    },
                    format = function (s, c) {
                        return s.replace(/{(\w+)}/g,
                            function (m, p) {
                                return c[p];
                            })
                    };

                return function (table, name) {
                    if (!table.nodeType) table = document.getElementById(table)
                    var ctx = {
                        worksheet: name || 'Worksheet',
                        table: table.innerHTML
                    }
                    window.location.href = uri + base64(format(template, ctx))
                }
            })()
        };

    }
);
define(
    '../epg2/EpgWeb.Dao',['require','exports','module'],function (require, exports, module) {
        EpgWeb.Dao = $.extend({}, Ancestor.Dao, {
            cfgName: {
                LiveType: "LiveType",
                LogType: "LogType",
                episodeGradeType: "EpisodeGradeType",
                liveProgramType: "LiveProgramType",
                liveChannelType: "LiveChannelType",
                getChannel: "getChannel"
            },
            channelId: null,
            getDataByName: function (targetName) {
                var responseData = EpgWeb.ajaxQueue.findResponseData(targetName);
                return responseData;
            },
            sendAjax: function (url, method, data, callback, authUrl) {
                var options = {
                    url: url,
                    dataType: 'json',
                    data: data,
                    type: method,
                    success: function (data) {
                        if (callback != null) {
                            callback.call(this, data);
                        }
                    },
                    error: function (data) {
                        if (callback != null) {
                            callback.call(this, data);
                        }
                    }
                };
                Ancestor.Dao.ajax(options, authUrl);
            },
            appendAuthUrl: function (options, authUrl) {
                options = $.extend({},options, {
                    beforeSend: function (request) {
                        var authBase = Ancestor.Util.getAuth('/vod/episodeLogList');
                        request.setRequestHeader('Sign', authBase.sign);
                        request.setRequestHeader("Time", authBase.clientTime);
                        request.setRequestHeader("From", authBase.from);
                        request.setRequestHeader("UserName", (auth.baseInfo.authInfo == null) ? "" : escape(auth.baseInfo.authInfo.userName).toLocaleLowerCase().replace(/%u/gi, '\\u'));
                    }
                })
                return options;
            },

            sendProxy: function (options, headers) {
                $.ajax(this.transToProxyOptions(options, headers));
            },
            transToProxyOptions: function (options, headers) {
                var requestData = {url: options.url, type: options.type, params: options.data, needCookie: true};
                if (headers != null) {
                    requestData.headers = headers;
                }
                var newOptions = {
                    url: EpgWeb.urlConfig.redirect,
                    type: "post",
                    dataType: "json",
                    timeout: options.timeout?options.timeout: 5000,
                    data: {"request": JSON.stringify(requestData), timeSign: new Date().getTime()},
                    success: function (data) {
                        options.success(data);
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        options.error(null);
                    }
                }
                return newOptions;
            },
            doGet: function (url, data, callback) {
                var dataArr = [];
                for (var key in data) {
                    dataArr.push(key + "=" + data[key]);
                }

                var options = {
                    url: url,
                    dataType: 'json',
                    data: dataArr.join("&"),
                    type: 'get',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                $.ajax(options);
            },
            doAuthData: function (handlerObj) {
                if (auth == null) {
                    auth = Ancestor.Auth;
                }
                auth.getAuthData({tips: 1, url: handlerObj.url}, function (rt) {
                    if (rt == null) {
                        if (handlerObj.hasOwnProperty("doSuccess")) {
                            handlerObj.doSuccess();
                        }
                    } else {
                        if (handlerObj.hasOwnProperty("doError")) {
                            handlerObj.doError();
                        }
                    }
                    if (handlerObj.hasOwnProperty("doFinal")) {
                        handlerObj.doFinal();
                    }
                });
            },
//            checkJSVersion: function (data, callback) {
//                //method, data, callback, authUrl) {
//                this.sendAjax("/api/version/check", "post", {data:JSON.stringify(data)}, callback);
//            }
            notifyAlert: function (sendData, callback) {
                var url = EpgWeb.urlConfig.notifyAlertUrl;
                var options = {
                    type: "post",
                    url: url,
                    dataType: "json",
                    data: {data: JSON.stringify(sendData)},
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/notify/alertPlatform");
            }

        })
    }
);
define(
    '../epg2/EpgWeb.Task',['require','exports','module'],function (require, exports, module) {
        EpgWeb.Task = (function () {
            var handler = function(data,callback){
                if (callback != null) {
                    callback.call(this, data);
                }
            }
            var getConfigType = function (typeName, callback, regName) {
                if (regName == null) {
                    regName = typeName;
                }
                return {
                    regName: regName,
                    options: {
                        type: "get",
                        url: EpgWeb.urlConfig.configs,
                        dataType: "json",
                        data: {type: typeName},
                        success: function(data){
                            handler.call(this, data,callback);
                        },
                        error: function(data){
                            handler.call(this, data,callback);
                        }
                    }
                }
            }

            var getChannel = function (regName,params) {
                return {
                    regName:regName,
                    options: {
                        type: "post",
                        url: EpgWeb.urlConfig.channelGet,
                        dataType: "json",
                        data: params
                    }
                }
            }
            return {
                getConfigType: getConfigType,
                getChannel:getChannel
            }
        })()
    }
);
define(
    '../epg2/EpgWeb.PingBack',['require','exports','module'],function (require, exports, module) {
        window.EpgWeb = window.EpgWeb || {
            version: '1.0'
        };


// [步骤名称 操作结果] [entityId=节目Id][msg=任意消息][stepInfo={json对象，用于携带其它信息}][cost=步骤执行耗时，可选]
        EpgWeb.PingBack = {
            PARAM_TYPE:{
                append_submit:402,
                normal_submit:403
            },
            typeArr: ["create_video", "submit_format"],
            doFoldList: function (originalData) {
                var retValue = originalData;
                try {
                    var newData = JSON.parse(retValue);
                    if (newData.list != null) {
                        newData.list = JSON.parse(newData.list)
                        var newFold = [];
                        var nodeStart = -100;
                        var nodeEnd = -100;
                        var curIndex = 0;
                        $.each(newData.list, function (i, element) {
                            curIndex = element;
                            if (curIndex > nodeEnd + 1) {
                                if (nodeStart >= 0) {
                                    newFold.push({ start: nodeStart, end: nodeEnd});
                                }
                                nodeStart = curIndex;
                                nodeEnd = curIndex;
                            } else if (curIndex == nodeEnd + 1) {
                                nodeEnd = curIndex;
                            }
                        })
                        if (nodeEnd >= nodeStart) {
                            newFold.push({ start: nodeStart, end: nodeEnd});
                        }
                        newData.list = newFold;
                        retValue = JSON.stringify(newData);
                    }
                } catch (e) {
                    console.log("error", e);
                }
                return retValue
            },
            transFormatData: function (wrapData) {
                var ret = {};
                ret.success = wrapData.success;
                if (wrapData.success == true) {
                    ret.successLogExpression = "[" + wrapData.funcType + " success]";
                } else {
                    ret.failLogExpression = "[" + wrapData.funcType + " error]";
                }
                ret.detail = "[entityId=" + wrapData.programId + "][stepInfo=" + this.doFoldList(wrapData.sendData) + "][plusMsg=" + wrapData.plusMsg + "]";
                wrapData.sendData = null;
                ret.keyId = "" + wrapData.programId;
                ret.serverIp = "" + wrapData.serverIp;
                ret.relationData = [
                    {description: "奇谱", columnName: "programId", "columnValue": "" + wrapData.programId, "isQueryParam": "0", "isQueryList": "1"}
                ];
                ret.paramType = wrapData.paramType ?  wrapData.paramType:this.PARAM_TYPE.append_submit;
                return  ret
            },
            doExecute: function (wrapData, callback) {
                var testUrl = "http://xiu-test-monitor-dev001-cqdx.qiyi.virtual/monitor-api/pingback/flow";
                var onlineUrl = "http://monitor.live.qiyi.domain/monitor-api/pingback/flow";
                var paramsArr = [];
                var retData = this.transFormatData(wrapData);
                paramsArr.push({keyName: "business", value: "live2vod"});
                paramsArr.push({keyName: "paramType", value: retData.paramType })
                if (retData.success) {
                    paramsArr.push({keyName: "successLogExpression", value: retData.successLogExpression})
                } else {
                    paramsArr.push({keyName: "failLogExpression", value: retData.failLogExpression})
                }
                paramsArr.push({keyName: "sendTime", value: new Date().getTime() })
                paramsArr.push({keyName: "detail", value: retData.detail});
                paramsArr.push({keyName: "keyId", value: retData.keyId})
                paramsArr.push({keyName: "serverIp", value: retData.serverIp}) //
                paramsArr.push({keyName: "relationData", value: retData.relationData})
                paramsArr.push({keyName: "checkToken", value: md5("business=live2vod|F@(LhCw79plfWd3$83#530")})

                var sendData = {}
                $.each(paramsArr, function (index, element) {
                    if (element.value != null) {
                        sendData[element.keyName] = element.value;
                    }
                })

                for (var key in wrapData) {
                    if(wrapData[key] != null){
                        sendData[key] = wrapData[key];
                    }
                }
                var options = {
                    url: auth.dev() ? testUrl : onlineUrl,
                    dataType: 'json',
                    data: sendData,
                    type: "post",
                    success: function (data) {
                        if (callback != null) {
                            callback.call(this, data);
                        }
                    },
                    error: function (data) {
                        if (callback != null) {
                            callback.call(this, data);
                        }
                    }
                }
                EpgWeb.Dao.sendProxy(options)
            },
            doQuickSend: function (wrapData) {
                this.doExecute(wrapData, function (data) {
                    console.log(data);
                })
            }
        }
    }
);
define(
    '../epg2/EpgWeb.PingBackCost',['require','exports','module'],function (require, exports, module) {
        window.EpgWeb = window.EpgWeb || {
            version: '1.0'
        };
//        business	业务名称	业务代码：PGC，CPP等	Y	string
//        name	服务名称	该服务名称需要和你在监控中所配置的名称一致	Y	string
//        cost	耗时	单位是毫秒	Y	sring	1000
//        sendTime	投递数据的时间戳	投递数据的时间戳（到秒一级）	Y	string	1493258494
//        detail	透传详细信息	想要传递过来的详细信息，如一条完整日志	N	json string
//        serverIp	机器IP地址	产生投递信息的机器IP	Y	string
//        checkToken	接口签名参数	接口签名参数	Y	string
        EpgWeb.PingBackCost = {
            doExecute: function (wrapData, callback) {
                var testUrl = "http://xiu-test-monitor-dev001-cqdx.qiyi.virtual/monitor-api/pingback/cost";
                var onlineUrl = "http://monitor.live.qiyi.domain/monitor-api/pingback/cost";
                var paramsArr = [];
                var retData = wrapData;
                paramsArr.push({keyName: "business", value: "live2vod"});
                paramsArr.push({keyName: "name", value: "zzd_jqh"});
                paramsArr.push({keyName: "cost", value: retData.costTime + ""});
                paramsArr.push({keyName: "sendTime", value: parseInt(new Date().getTime() / 1000 )  })
                paramsArr.push({keyName: "detail", value: retData.detail});
                paramsArr.push({keyName: "serverIp", value: retData.serverIp}) //
                paramsArr.push({keyName: "checkToken", value: md5("business=live2vod|F@(LhCw79plfWd3$83#530")})

                var sendData = {}
                $.each(paramsArr, function (index, element) {
                    if (element.value != null) {
                        sendData[element.keyName] = element.value;
                    }
                })
                var options = {
                    url: auth.dev() ? testUrl : onlineUrl,
                    dataType: 'json',
                    data: sendData,
                    type: "post",
                    success: function (data) {
                        if (callback != null) {
                            callback.call(this, data);
                        }
                    },
                    error: function (data) {
                        if (callback != null) {
                            callback.call(this, data);
                        }
                    }
                }
                EpgWeb.Dao.sendProxy(options)
            },
            doQuickSend: function (wrapData) {
                this.doExecute(wrapData, function (data) {
                    console.log(data);
                })
            },
            doTest: function (enterData) {
                var demo = $.extend({}, enterData, { costTime: 30000, serverIp: "127.0.0.1", detail: JSON.stringify({msg: "demo"})})
                this.doQuickSend(demo)
            }
        }
    }
);
/**
 * Created by karkarrotxu on 2016/11/8.
 */
define(
    '../vod/VOD',['require','exports','module'],function (require, exports, module) {
        window.VOD = window.VOD || {
            version: '1.0',
            g_i: 0,
            g_mi: 0
        };
        VOD.Constant = {
            baseApiUrl: "/api/",
            baseModeApiUrl_test: "http://10.23.70.33:7007/",
            baseModeApiUrl_produce: "http://dot.live.qiyi.domain/",
            //    thirdUrl_peditor_submit:"http://lego.iqiyi.com/peditor/submit",
            thirdUrl_simple_video: 'http://lego.iqiyi.com/suggest/simple-video',
            thirdUrl_channel: 'http://lego.iqiyi.com/suggest/operation', // 频道
            thirdUrl_album: 'http://lego.iqiyi.com/suggest/album',
            thirdUrl_legoProgramIdUrl: 'http://lego.iqiyi.com/peditor/submit', //lego获取programid接口
            //cpUrl : 'http://lego.iqiyi.com/live2VOD/cp/search', // 合作方接口
            thirdUrl_cpUrl: 'http://dispatch.live2vod.qiyi.domain/v1/partner/find',  //合作方接口 线上
            thirdUrl_test_cpUrl: 'http://10.23.70.33:7004/v1/partner/find',  //合作方接口 线上
            thirdUrl_locationUrl: 'http://lego.iqiyi.com/suggest/location-type',  //地区suggest接口
            devMode: auth.dev()
        }

        VOD.urlConfig = (function () {
            var useUrl = VOD.Constant.baseApiUrl;
            var redirectUrl = useUrl + "redirect";
            var modifyUrl = ( VOD.Constant.devMode ? VOD.Constant.baseModeApiUrl_test : VOD.Constant.baseModeApiUrl_produce ) + "v1/ablum/modify";
            var partnerUrl = VOD.Constant.devMode ? VOD.Constant.thirdUrl_test_cpUrl : VOD.Constant.thirdUrl_cpUrl;
            return {
                modifyUrl: modifyUrl,
                redirect: redirectUrl,
                partnerUrl: partnerUrl
            }
        })()
    }
);
define(
    '../vod/VOD.Action',['require','exports','module'],function (require, exports, module) {
        VOD.Action = (function () {
            var editForm = null;
            var newsEditForm = null;
           // var editMergeForm = null;

            function initWindowEvent(){
                window.onbeforeunload = function () {
                    var warning = "确认要重新打点吗？";
                    return warning;
                }
                $(window).unbind("keydown").bind("keydown", function (e) {
                    VOD.Util.globalEvent(e);
                });
                window.onresize = function () {
                    VOD.Util.browserZoomTips();
                    VOD.Util.LayoutInit();
                    VOD.Util.doNewsGridResize();
                };
            }

            var editRun = function () {
                if(editForm == null){
                    editForm = new VOD.Edit($.extend(true, {
                        $FrameGrid:$('#frame_list'),
                        $AdvertGrid:$('#advert_list')
                        // '$form': $('form[role=form]')
                    }, {}));
                    setTimeout(function () {
                        $("body footer").hide();
                        console.log("隐藏footer");
                    },1000)
                    editForm.init();
                    initWindowEvent();
                }
                console.log(' editRun ');
            }
            var newsEditRun = function () {
                if(newsEditForm == null){
                    newsEditForm = new VOD.NewsEdit($.extend(true, {
                        $FrameGrid:$('#frame_list'),
                        $AdvertGrid:$('#advert_list'),
                        $NewsGrid:$('#news_list')
                        // '$form': $('form[role=form]')
                    }, {}));
                    setTimeout(function () {
                        $("body footer").hide();
                        console.log("隐藏footer");
                    },2000)
                    newsEditForm.newsInit();
                    initWindowEvent();
                }
                console.log(' editRun ');
            }

//            var editMergeRun = function(){
//                if(editMergeForm == null){
//                    editMergeForm = new VOD.EditMerge($.extend(true, {
//                        $FrameGrid:$('#frame_list'),
//                        $AdvertGrid:$('#advert_list'),
//                        $NewsGrid:$('#news_list')
//                        // '$form': $('form[role=form]')
//                    }, {}));
//                    setTimeout(function () {
//                        $("body footer").hide();
//                        console.log("隐藏footer");
//                    },2000)
//                    editMergeForm.init();
//                    initWindowEvent();
//                }
//
//            }
            return {
                editRun: editRun,
                newsEditRun:newsEditRun
           //     editMergeRun:editMergeRun
            }
        })();
    }
);
///import js-src/lib/
///import js-src/com/
define('../vod/VOD.Config',['require','exports','module'],function (require, exports, module) {
    VOD.Config = $.extend({}, {}, {
        BIG_PIC_MODE: 'style="width:264px;height:204px"',
        SMALL_PIC_MODE: 'style="width:104px;height:64px"',
        Global: {
            picWH: 'style="width:104px;height:64px"',
            smallPic: true,
            isClicked: false,
            error: '',
            channelInfo: [],
            sty2Data: {},
            d_sty2Data: [], // 广告头和尾
            noneDataNum: 0,
            fp_pos: 0,
            statisticOcrTitle: ""
        },

        HELP_DATA: [
            ["点击 + F 键", "打开始帧"],
            ["点击 + D 键", "打结束帧"],
            ["点击 + S 键", "打视频封面"],
            ["点击 + A 键", "提交打点"],
            ["点击 + V 键", "打删除(广告)的开始帧"],
            ["点击 + C 键", "打删除(广告)的结束帧"],
            ["点击 + Z 键", "提交删除"],
            ["点击 + Q 键", "片头、片尾精确化裁剪"],
            ["点击 + W 键", "时间片预览"],
            ["R 键", "标题OCR"],
            ["X 键", "拆条列表"],
            ["上、下、左、右方向键", "上、下、左、右切换"]
        ],
        HELP2_DATA: [
            ["点击 + F 键", "打入点"],
            ["点击 + D 键", "打出点"],
            ["点击 + S 键", "打视频封面"],
            ["点击 + Q 键", "入点、出点、封面精确化裁剪"],
            ["点击 + W 键", "时间片预览"],
            ["X 键", "拆条列表"],
            ["上、下、左、右方向键", "上、下、左、右切换"]
        ],
        ZOOM_HINT: {
            BIG: '您当前浏览器处于放大状态,按<strong>ctrl+0</strong>使用体验更佳!',
            SMALL: '您当前浏览器处于缩小状态,按<strong>ctrl+0</strong>使用体验更佳!'
        },
        PGC: 0,
        UGC: 1,
        adLibHead: 0, // 片头
        adLibTail: 1, // 片尾
        adLib: 2,// 广告

        RED_LAYOUT: '<div class="layout transparent red" onClick="this.remove();">&nbsp;</div>',
//["index", "inpoint", "outpoint", "title","channel","album","cover", "status", "operate"]
        TABLE_COLMODEL_CONFIG: {
            index: {
                name: "index",
                index: 'index',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            inpoint: {
                name: "sTime",
                index: 'sTime',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            outpoint: {
                name: "eTime",
                index: 'eTime',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            title: {
                name: "title",
                index: 'title',
                title: false,
                width: 120,
                sortable: false
            },
            news_title: {
                name: "title",
                index: 'title',
                title: false,
                width: 205,
                sortable: false,
                formatter: function (v, o, r) {
                    return   VOD.Util.formatter.news_title(v, o, r);
                }
            },
            channel: {
                name: "channel",
                index: 'channel',
                title: false,
                width: 60,
                sortable: false,
                align: "center"
            },
            album: {
                name: "album",
                index: 'album',
                title: false,
                width: 60,
                sortable: false,
                align: "center"
            },
            cover: {
                name: "pic",
                index: 'pic',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            status: {
                title: false,
                width: 60,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return   "已生成";
                }
            },
            operate_frame: {
                index: 'operate',
                title: false,
                width: 160,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return  VOD.Util.formatter.operate_frame(v, o, r);
                }
            },
            operate_advert: {
                index: 'operate',
                title: false,
                width: 160,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.operate_advert(v, o, r);
                }
            },
            operate_news: {
                index: 'operate',
                title: false,
                width: 57,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.operate_news(v, o, r);
                }
            },
            operate_news_merge:{
                index: 'operate',
                title: false,
                width: 57,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.operate_news_merge(v, o, r);
                }
            },

            error_hint: {
                title: false,
                width: 70,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.error_hint(v, o, r);
                }
            },
            news_id: {
                name: "regId",
                index: 'regId',
                title: false,
                width: 40,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.news_id(v, o, r);
                }

            },
            hidden_news_id:{
                name: "hidden_news_id",
                title: false,
                sortable: false,
                hidden: true,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.hidden_news_id(v, o, r);
                }
            }
        },
        TABLE_FRAME_LIST: {
            multiselect: false,
            datatype: "local",
            height: 450,
            rowNum: 10,

            caption: "拆条列表",
            colNames: ["序号" , "入点", "出点", "标题 ", "频道", "专辑", "封面", "状态", "操作" ],
            colModel: ["index", "inpoint", "outpoint", "title", "channel", "album", "cover", "status", "operate_frame"],
            pager: "#frame_pager",
            onPaging: function (pgButton) {
                var retValue = VOD.Util.pageBeanPageHandler("frame_list", "frame_pager", VOD.Config.PageBeanFrame, pgButton);
                if (retValue != null) {
                    $("#frame_list")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },
        TABLE_ADVERT_LIST: {
            multiselect: false,
            datatype: "local",
            height: 450,
            caption: "广告列表",
            colNames: ["序号" , "入点", "出点", "标题 ", "状态", "操作"  ],
            colModel: ["index", "inpoint", "outpoint", "title", "status", "operate_advert"],
            rowNum: 10,
            pager: "#advert_pager",
            onPaging: function (pgButton) {
                var retValue = VOD.Util.pageBeanPageHandler("advert_list", "advert_pager", VOD.Config.PageBeanAdvert, pgButton);
                if (retValue != null) {
                    $("#advert_list")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },
        TABLE_NEWS_LIST: {
            multiselect: false,
            datatype: "local",
            height: window.screen.height - 1080 + 355 ,
            toolbar: [true, "top"],
            caption: "新闻拆条列表",
            colNames: ["序号", "标题" , "入点", "出点", "封面 ", "操作","隐藏主键"],
            colModel: ["news_id", "news_title", "inpoint", "outpoint", "cover", "operate_news","hidden_news_id"],
            pager: "#news_pager",
//            multiselect: true,
            rowNum: 100,
            onPaging: function (pgButton) {
                var retValue = VOD.Util.pageBeanPageHandler("news_list", "news_pager", VOD.Config.PageBeanNews, pgButton);
                if (retValue != null) {
                    $("#news_list")[0].addJSONData(retValue)
                }
                return "stop";
            },
            beforeSelectRow: function (rowid, e) {
                var describedby = $(e.target).attr("aria-describedby");
                if(describedby != null){
                    var cellKey =  describedby.replace("news_list_", "");
                    switch (cellKey) {
                        case "checked":
                            return false;
                        case "pic":
                        case "sTime":
                        case "eTime":
                            var rowData = VOD.Config.PageBeanNews.findData("regId", rowid);
                            VOD.Util.setHighLight(rowData);
                            VOD.Util.fromLIstJump(parseInt($(e.target).html()));
                            return true;
                        case "myTitle":
                            var oldValue =  $(e.target).html();
                            $(e.target).html("<input type='text' style='width:185px' data-id='"+rowid+"'   onblur='VOD.Util.doChangeTitle(this)' value='"+oldValue+"'>");
                            var inputElement = $(e.target).find("input");
                            VOD.Util.limitWordCount(inputElement, 43);
                            inputElement.focus();
                            break;
                    }
                }
                var rowData = VOD.Config.PageBeanNews.findData("regId", rowid);
                VOD.Util.setHighLight(rowData);
                VOD.Util.fromLIstJump(rowData.sTime);
                if(e.target.tagName == "A"){
                    $("#news_list").jqGrid('setSelection', rowid);
                }
                return true;
            },
            localReader: {
                id: "regId",
                root: "rows",
                page: "page",
                total: "total",
                records: "records"
            }
        },


        INFO_COMPLETE_WAIT_DO: "拆条完成，还有N条未审核",
        INFO_UN_COMPLETE: "正在拆条，还有N条未审核",
        INFO_COMPLETE: "等待开播",
        PageBeanFrame: null,
        PageBeanAdvert: null,
        PageBeanNews: null,
        PageBeanTemp: null,
        INIT_SUCCESS: false,
        EDIT_MODE_TYPE: 1,// 1:拆条参数,2:新闻发布
        SORT_RULE:{
          asc_news_regId:function(a, b) {
            return a.regId > b.regId ? 1 : -1
          },
          asc_news_sTime:function (a, b) {
              return a.sTime > b.sTime ? 1 : -1
          }
        },
        KEY_CODE: {
            A: 65,
            C: 67,
            D: 68,
            F: 70,
            ESC: 27,
            Q: 81,
            R: 82,
            S: 83,
            V: 86,
            W: 87,
            X: 88,
            Z: 90,
            ZERO: 48,
            LEFT: 37,
            UP: 38,
            RIGHT: 39,
            DOWN: 40
        }
    })
});
define('../vod/VOD.Util',['require','exports','module'],function (require, exports, module) {
    VOD.Util = $.extend(true, {}, EpgWeb.Util, {
        formatter: {
            operate_frame: function (cellvalue, options, rowObject) {
                return '<button type="button" class="btn btn-info" onclick="VOD.Util.delFrame(' + rowObject.index + ')">删除</button>' +
                    '<button  type="button" class="btn" onclick="VOD.Player.reviewOne(\'' + rowObject.sTime + '\',\'' + rowObject.eTime + '\',\'打点\');">预览</button>' +
                    '<button type="button" class="btn" onclick="VOD.Util.fromLIstJump(' + rowObject.sTime + ');" >跳转</button>';
            },
            operate_advert: function (cellvalue, options, rowObject) {
                return '<button type="button" class="btn btn-info" onclick="VOD.Util.delAdvert(' + rowObject.index + ')">删除</button>' +
                    '<button  type="button" class="btn" onclick="VOD.Player.reviewOne(\'' + rowObject.sTime + '\',\'' + rowObject.eTime + '\',\'删除\');">预览</button>' +
                    '<button type="button" class="btn" onclick="VOD.Util.fromLIstJump(' + rowObject.sTime + ');" >跳转</button>';
            },
            news_title: function (cellvalue, options, rowObject) {
                if (cellvalue.length == 0) {
                    return "";
                }
                if (VOD.Config.PageBeanNews == null) {
                    return "";
                }
                var findData = VOD.Config.PageBeanNews.findData("regId", parseInt(rowObject.regId));
                if (findData.showTitle == null) {
                    var titleArr = JSON.parse(cellvalue);
                    if (titleArr.length == 0) {
                        findData.showTitle = "";
                    } else {
                        findData.showTitle = titleArr[0];
                    }
                }
                return '<div style="min-height: 20px;min-width: 100px" aria-describedby="myTitle">' + findData.showTitle + '</div><a style="text-underline-position: below;color:blue" onclick="VOD.Util.AlterTitle(' + rowObject.regId + ' )">选择</a>'
            },
            operate_news: function (cellvalue, options, rowObject) {
                var ret = '<a style="text-underline-position: below;color:blue" onclick="VOD.Util.viewNews(' + rowObject.regId + ' )">预览</a>|' +
                    '<a style="text-underline-position: below;color:blue" onclick="VOD.Util.publishNews(' + rowObject.regId + ' )">发布</a>|' +
                    '<a style="text-underline-position: below;color:blue" onclick="VOD.Util.delNews(' + rowObject.regId + ' )">删除</a>'
                if (rowObject.isMergeMode) {
                    ret += '|<br><a style="text-underline-position: below;color:blue" onclick="VOD.Util.undoMerge(' + rowObject.regId + ' )">撤销合并</a>';
                }
                return ret;
            },


            error_hint: function (cellvalue, options, rowObject) {
                return "";
            },
            news_id: function (cellvalue, options, rowObject) {
                var ret = "";
                ret = "<input type='checkbox' onclick='VOD.Util.doRowSelected(this)' aria-describedby='checked'  value='@val' @checked  >".replace("@checked", (rowObject.checked ? "checked" : "")).replace("@val", cellvalue) + cellvalue
                return ret;
            },
            hidden_news_id: function (cellvalue, options, rowObject) {
                return rowObject.regId;
            }
        },

        getUrlParams: function () {
            // var queryStringArr = location.search.match(new RegExp("[\?\&][^\?\&]+=[^\?\&]+", "g")),
            var queryStringArr = decodeURIComponent(location.search).substring(1).split("&"),
                queryStringObj = {}
            var itemArr = [];
            try {
                if (queryStringArr != null) {
                    for (var i = 0; i < queryStringArr.length; i++) {
                        itemArr = queryStringArr[i].split("=");
                        if (i == 0) {
                            queryStringObj['channel_code'] = itemArr[0];
                            queryStringObj['ip'] = itemArr[1];
                        }
                        else {
                            queryStringObj[itemArr[0]] = itemArr[1];
                        }
                    }
                }
            }
            catch (e) {
                console.log("URL地址参数有误，请确认！")
                //  VOD.Plugin.tips("error","URL地址参数有误，请确认！");
            }
            return queryStringObj;
        },
        LayoutInit: function () {
            $(".tab-content").css({
                height: VOD.Util.getPageRelativeMesurement().height - 300 - 10 - 49 - 20 - 2
            });
            $("#makedImg").css({
                height: VOD.Util.getPageRelativeMesurement().height - 90 - 2
            });
        },
        getUserAgent: function () {
            var ua = navigator.userAgent;

            var result = {
                isStrict: document.compatMode == "CSS1Compat",
                isGecko: /gecko/i.test(ua) && !/like gecko/i.test(ua),
                isWebkit: /webkit/i.test(ua)
            };

            try {
                if (/(\d+\.\d+)/.test(external.max_version)) {
                    result.maxthon = +RegExp['\x241'];
                }
            } catch (e) {
                console.log(e);
            }

            if (/msie (\d+\.\d+)/i.test(ua)) {
                result.ie = document.documentMode || +RegExp['\x241'];
            } else if (/trident(\.*?)/i.test(ua)) {
                result.ie = document.documentMode || +RegExp['\x241'];
            } else if (/chrome\/(\d+\.\d+)/i.test(ua)) {
                result.chrome = +RegExp['\x241'];
            } else if (/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(ua) && !/chrome/i.test(ua)) {
                result.safari = +(RegExp['\x241'] || RegExp['\x242']);
            } else if (/firefox\/(\d+\.\d+)/i.test(ua)) {
                result.firefox = +RegExp['\x241'];
            } else if (/opera(?:\/| )(\d+(?:\.\d+)?)(.+?(version\/(\d+(?:\.\d+)?)))?/i.test(ua)) {
                result.opera = +(RegExp["\x244"] || RegExp["\x241"]);
            }

            return result;
        },
        detectBrowserSupport: function (browser) {
            var support = false;
            if (browser.isWebkit || browser.firefox) {
                support = true;
            }
            if (browser.ie && browser.ie >= 9) {
                support = true;
            }
            if (!support) {
                var str = '警告！您使用的浏览器版本过低，为了获得更好使用体验。请使用Chrome、Firefox或IE10浏览器。谢谢！';
                VOD.Plugin.tips("error", str);
            }

        },

        // 加载合作方信息
        setCooperativePartner: function (categoryName) {
            var self = this;
            $('#cp').html("");
            var videoTypeMinusOne = self.isVideoType1();
            if (videoTypeMinusOne) {
                return;
            }
            // 关联合作方信息
            VOD.Dao.getCooperativePartner({
                'channeltype': categoryName,
                'channelalias': VOD.Dao.getParamsData().channel_name,
                'ptype': 'UGC',
                'pageNo': 0,
                'pageSize': 1000
            }, function (cps) {
                if (cps == undefined) {
                    return;
                }
                var cpStr = '<option uid="" partnerId="" episodeType="' + VOD.Config.PGC + '"></option>';
                var i = 0,
                    selected = '';
                $.each(cps, function (i, item) {
                    if (i++ === 0) {
                        selected = "selected";
                    } else {
                        selected = "";
                    }
                    cpStr += '<option uid="' + item.ugcid + '" ' + selected + ' partnerId="' + item.qipuid + '" episodeType="' + VOD.Config.UGC + '">' + item.ugcmsg + '</option>';
                })
                $('#cp').html(cpStr);
            });
        },
        setCooperativePartner_tab3: function (categoryName) {
            var self = this;
            $('#tab3_cp').html("");
            // 关联合作方信息
            VOD.Dao.getCooperativePartner({
                'channeltype': categoryName,
                'channelalias': VOD.Dao.getParamsData().channel_name,
                'ptype': 'UGC',
                'pageNo': 0,
                'pageSize': 1000
            }, function (cps) {
                if (cps == undefined) {
                    return;
                }
                var cpStr = '<option uid="" partnerId="" episodeType="' + VOD.Config.PGC + '"></option>';
                var i = 0,
                    selected = '';
                $.each(cps, function (i, item) {
                    if (i++ === 0) {
                        selected = "selected";
                    } else {
                        selected = "";
                    }
                    cpStr += '<option uid="' + item.ugcid + '" ' + selected + ' partnerId="' + item.qipuid + '" episodeType="' + VOD.Config.UGC + '">' + item.ugcmsg + '</option>';
                })
                $('#tab3_cp').html(cpStr);
            });
        },

        compareTime: function (beginTime, endTime) {

            var beginTimes = beginTime.substring(0, 10).split('-');
            var endTimes = endTime.substring(0, 10).split('-');

            beginTime = beginTimes[1] + '-' + beginTimes[2] + '-' + beginTimes[0] + ' ' + beginTime.substring(10, 19);
            endTime = endTimes[1] + '-' + endTimes[2] + '-' + endTimes[0] + ' ' + endTime.substring(10, 19);

            var a = (Date.parse(endTime) - Date.parse(beginTime)) / 3600 / 1000;
            if (a < 0) {
                return -1;
            } else if (a > 0) {
                return 1;
            } else if (a == 0) {
                return 0;
            } else {
                return 'exception'
            }
        },
        detectZoom: function () {
            var ratio = 0,
                screen = window.screen,
                ua = navigator.userAgent.toLowerCase();

            if (window.devicePixelRatio !== undefined) {
                ratio = window.devicePixelRatio;
            } else if (~ua.indexOf('msie')) {
                if (screen.deviceXDPI && screen.logicalXDPI) {
                    ratio = screen.deviceXDPI / screen.logicalXDPI;
                }
            } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
                ratio = window.outerWidth / window.innerWidth;
            }

            if (ratio) {
                ratio = Math.round(ratio * 100);
            }

            return ratio;
        },
        browserZoomTips: function () {
            $('[role=alert1]').hide();
            if (VOD.Util.detectZoom() > 100) {
                $('[role=alert]').html(VOD.Config.ZOOM_HINT.BIG).show();
            } else if (VOD.Util.detectZoom() < 100) {
                $('[role=alert]').html(VOD.Config.ZOOM_HINT.SMALL).show();
            } else {
                $('[role=alert]').html("").hide();
            }
        },

        // tab标签上自动拆条可用与否
        autoSegmentationTabOptions: function (options) {
            var defaults = {
                name: ''
            };
            options = $.extend({}, defaults, options);

            if (options.name == 'auto-segmentation-tab') {
                $(".nav-opt").find("input").prop("disabled", false);
                $(".nav-opt").find("button").prop("disabled", false).addClass("nav-opt-enable");
            } else {
                $(".nav-opt").find("input").prop("disabled", true);
                $(".nav-opt").find("button").prop("disabled", true).removeClass("nav-opt-enable");
            }
        },
        getPageRelativeMesurement: function () {
            return {
                width: $(window).width(),
                height: $(window).height()
            };
        },

        isJumpData: function (data, type) {
            if (type == 1) {
                var regJumpData = /^(\d{2}):(\d{2}):(\d{2})$/;
                if (!regJumpData.test(data)) {
                    return false;
                }
                return true;
            } else {
                if (isNaN(data)) {
                    return false;
                }
                return true;
            }
        },
        isVideoType1: function () {
            if ($('input[name=videotype]:checked').val() == -1)
                return 0;
            else
                return 1;
        },

        globalEvent: function (e) {
            console.log("e.keyCode", e.keyCode);
            var self = this;
            var settings = VOD.Dao.settings;
            var global = VOD.Config.Global;
            /*
             // 自动拆条相关
             if (!$('[action-name="segmentation-params-tab"]').parent('li').hasClass('active'))
             return;
             */

            // textarea去除快捷键
            if ($('textarea').is(":focus")) {
                return;
            }
            if ($('input').is(":focus")) {
                return;
            }

            if (e.which == VOD.Config.KEY_CODE.ESC) { // 打点精确化,调出该图片所有上所对应的所有帧  对应快捷键为 ESC
                VOD.AccurateFrame.accurateStartEndRemove();
                return false;
            }

            // 文本框去除快捷键
            if ($("#cForm,#dForm,#tab3").find('input[type=text]').is(":focus")) {
                return;
            }

            if (this.isTab2Show() || this.isTab3Show()) {
                var red = $('.red').parent().find("div");
                if (red.length == 0) {
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.F) { //打开始
                    //  VOD.AccurateFrame.updateAccurateFrame({head: '', headSetted: false})
                    VOD.NewsHighlight.setNewStart()
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.D) { //打结束
                    //  VOD.AccurateFrame.updateAccurateFrame({end: '', endSetted: false})
                    VOD.NewsHighlight.setNewEnd()
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.S) { //打封面
                    VOD.NewsHighlight.setNewImage()
                    return;
                }
            } else {
                if (e.keyCode == VOD.Config.KEY_CODE.R) // ocr快捷键 R
                {
                    if (!self.isVideoType1()) {
                        if ($("#ocr").hasClass("disabled")) {
                            VOD.Plugin.tips("error", '当前ocr不可用！');
                        }
                        else {
                            $("#ocr").trigger("click");
                        }
                    }
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.ZERO && e.ctrlKey) {
                    $('[role="alert"]').hide();
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.Z) { //提交删除
                    if (self.del_submit()) {
                        //alert('删除成功');
                        VOD.Plugin.tips("success", "删除成功");
                    }
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.A) { //提交打点
                    if (self.dot_submit()) {
                        //alert('打点成功');
                        VOD.Plugin.tips("success", "打点成功");
                    }
                    $('#addInfo').removeAttr('disabled').html('提交');
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.V) { //删除开始
                    if (settings.stime >= 0) {
                        var red = $('.red').parent().find("div");

                        if (red.hasClass('ad-l') || red.hasClass('fragment-r') || red.hasClass('fragment-l')) {
                            return false;
                        }

                        $('.ad-l').remove();
                        if (!$('.old').hasClass('ad-l') && !$('.old').hasClass('ad-r') && $('.old').hasClass('fragment-r') && $('.old').hasClass('fragment-l')) {
                            $('.old').remove();
                        }
                        $('.red').addClass('ad-l');
                        $('.ad-l').removeClass('ad-r');
                        $('.ad-l').html("广<br />告<br />头");
                        $('input[name=d_sTime]').val(settings.stime);
                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.C) { //删除结束
                    if (settings.etime >= 0) {
                        var red = $('.red').parent().find("div");

                        if (red.hasClass('ad-r') || red.hasClass('fragment-r') || red.hasClass('fragment-l')) {
                            return false;
                        }
                        var tmp_stime = $('input[name=d_sTime]').val();
                        if (tmp_stime.length && parseInt(tmp_stime) > parseInt(settings.etime)) {
                            //alert('起始帧不能大于结束帧!');
                            VOD.Plugin.tips("error", "起始帧不能大于结束帧");
                            return false;
                        }
                        $('.ad-r').remove();
                        if (!$('.old').hasClass('ad-r') && !$('.old').hasClass('ad-l') && $('.old').hasClass('fragment-r') && $('.old').hasClass('fragment-l')) {
                            $('.old').remove();
                        }
                        $('.red').addClass('ad-r');
                        $('.ad-r').removeClass('ad-l');
                        $('.ad-r').html("广<br />告<br />尾");
                        $('input[name=d_eTime]').val(settings.etime);
                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.F) { //打开始
                    if (settings.stime >= 0) {
                        var red = $('.red').parent().find("div");

                        if (red.hasClass('ad-l') || red.hasClass('ad-r') || red.hasClass('fragment-l')) {
                            return false;
                        }
                        $('.fragment-l').remove();
                        if (!$('.old').hasClass('fragment-l') && !$('.old').hasClass('fragment-r') && $('.old').hasClass('ad-r') && $('.old').hasClass('ad-l')) {
                            $('.old').remove();
                        }

                        $('.red').removeClass('fragment-r');
                        $('.red').addClass('fragment-l');
                        $('.fragment-l').html("片<br />头");
                        $('input[name=sTime]').val(settings.stime);

                        VOD.AccurateFrame.updateAccurateFrame({head: '', headSetted: false})
                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.D) { //打结束
                    if (settings.etime) {
                        var red = $('.red').parent().find("div");
                        if (red.hasClass('ad-l') || red.hasClass('ad-r') || red.hasClass('fragment-r')) {
                            return false;
                        }
                        tmp_stime = $('input[name=sTime]').val();
                        if (tmp_stime.length && parseInt(tmp_stime) > parseInt(settings.etime)) {
                            //alert('起始帧不能大于结束帧!');
                            VOD.Plugin.tips("error", "起始帧不能大于结束帧");
                            return false;
                        }
                        $('.fragment-r').remove();
                        if (!$('.old').hasClass('fragment-r') && !$('.old').hasClass('fragment-l') && !$('.old').hasClass('ad-l') && !$('.old').hasClass('ad-r')) {
                            $('.old').remove();
                        }

                        $('.red').removeClass('fragment-l');
                        $('.red').addClass('fragment-r');
                        $('.fragment-r').html("片<br />尾");
                        $('input[name=eTime]').val(settings.etime);
                        var s_sTime = $('input[name=sTime]').val();
                        if ($('input[name=videotype]:checked').val() == -1) {
                            var show = settings.taskid + '-' + VOD.Dao.getParamsData().channel_name + '-' + settings.today + '-' + s_sTime + '-' + settings.etime;
                            if ($('input[name=videoName]').val() == "") {
                                $('input[name=videoName]').val(show);
                            }
                            var ocrFirstTitle = VOD.Util.binSearchOcrTitle(tmp_stime, settings.etime).shift();
                            if (ocrFirstTitle) {
                                $("input[name=videoName]").val(ocrFirstTitle);
                                $("input[name=videoName]").attr("eut", encodeURIComponent(ocrFirstTitle));
                            }
                        }
                        VOD.AccurateFrame.updateAccurateFrame({end: '', endSetted: false})

                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.S) { //打图片
                    if (settings.pic >= 0) {
                        if ($('.layout').hasClass('red block') || $('.layout').hasClass('blue block') || $('.layout').hasClass('red blue yellow block')) {
                            return false;
                        }
                        $('.block').remove();
                        $('.red').addClass('block');
                        $('input[name=imageId]').val(settings.pic);
                    }
                    return;
                }
            }

            if (e.which == VOD.Config.KEY_CODE.Q) { // 打点精确化,调出该图片所有上所对应的所有帧  对应快捷键为 q
                VOD.AccurateFrame.handler_keyCodeQ();
                return;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.W) // 鼠标悬浮快捷键w
            {
                var playOneInfo = VOD.Dao.playOneInfo;
                if (playOneInfo.mouseenter == true) {
                    VOD.Player.updatePosition({left: playOneInfo.left, top: playOneInfo.top})
                    VOD.Player.viewOne(playOneInfo.time);
                }
                return;
            }

            if (e.keyCode == VOD.Config.KEY_CODE.X) // ocr快捷键 x
            {
                VOD.Evt.ShowAndHideSegmentationList();
                return;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.LEFT) { //左
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.LEFT, settings);
                return false;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.RIGHT) { //右
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.RIGHT, settings);
                return false;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.UP) { //上
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.UP, settings);
                return false;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.DOWN) { //下
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.DOWN, settings);
                return false;
            }
        },

        dealDirectionKey: function (arrow, settings) {
            var currentTarget = parseInt($(".red").parent().find(".pid").text().replace(/\s+/g, ""));
            switch (arrow) {
                case   VOD.Config.KEY_CODE.UP:
                    currentTarget = currentTarget - VOD.Dao.settings.linePicNum;
                    break;
                case VOD.Config.KEY_CODE.DOWN:
                    currentTarget = currentTarget + VOD.Dao.settings.linePicNum;
                    break;
                case   VOD.Config.KEY_CODE.LEFT:
                    currentTarget--;
                    break;
                case   VOD.Config.KEY_CODE.RIGHT:
                    currentTarget++;
                    break;
            }
            if (currentTarget < 0) {
                currentTarget = 0;
            }
            $(".red").parent().find(".layout").removeClass("red").addClass("old");
            if (currentTarget >= parseInt($('#picNum').text())) {
                currentTarget = parseInt($('#picNum').text()) - 1;
            }
            settings.pic = settings.etime = settings.stime = currentTarget;
            var newTargetParent = $("#img-" + currentTarget).parent();
            if (newTargetParent.find(".layout").length > 0) {
                newTargetParent.find(".layout").addClass("red");
            } else {
                $(newTargetParent).append(VOD.Config.RED_LAYOUT)
            }
        },
        setHighLight: function (rowData) {
            var options = {};
            options.st = rowData.sTime
            options.et = rowData.eTime
            options.id = rowData.regId
            options.pic = rowData.pic
            options.bgColor = 'cfff';
            options.color = 'c09f';
            VOD.NewsHighlight.setHighLight(options);

        },
        delFrame: function (rowId) {
            SystemDialog.queryConfirm("确认删除么?", function (flag) {
                if (flag === true) {
                    var findData = VOD.Config.PageBeanFrame.findData("index", rowId);
                    if (findData != null) {
                        VOD.Config.PageBeanFrame.delOne(findData)
                        VOD.Util.updateGridFrame();
                        VOD.Util.delOne("打点", findData.sTime, findData.eTime);
                    }
                }
            })
        },

        viewNews: function (rowId) {
            var findData = VOD.Config.PageBeanNews.findData("regId", rowId);
            VOD.Util.doReview(findData.sTime, findData.eTime, false)
        },
        publishNews: function (rowId) {
            VOD.Util.readPublishFrameData(rowId);
            var findData = VOD.Config.PageBeanNews.findData("regId", rowId);
            $("li[aria-controls=tab3]").show();
            var panel = $("#tab3");
            panel.show();
            $("span[name=tabName]").html("序号" + rowId + "发布");
            $("#navDiv").tabs({active: 2});
            panel.find("input[name=tab3_title]").val(findData.showTitle);
            panel.find("input[name=tab3_inpoint]").val(findData.sTime);
            panel.find("input[name=tab3_outpoint]").val(findData.eTime);
            panel.find("input[name=tab3_imageId]").val(findData.pic);
            panel.find("input[name=tab3_priority][value=0]").prop("checked", true);
            panel.find("input[name=tab3_video_dpi][value=3]").prop("checked", true);
            $("#cover_img").attr("src", $("#img-" + findData.pic).attr("src"));
            $("input[name=tab3_categoryName]").suggest("setValue", "");
            $("input[name=tab3_albumName]").suggest("setValue", "");
            panel.find("input[name=tab3_title]").keyup();
        },
        delNews: function (rowId, skipQuery) {
            skipQuery = skipQuery === true ? true : false;
            var findData = VOD.Config.PageBeanNews.findData("regId", rowId);
            var toRemoveArr = [];
            if (findData != null) {
                if (findData.isMergeMode) {
                    if (findData.toRemoveArr.length > 0) {
                        toRemoveArr = findData.toRemoveArr;
                    }
                } else if (findData.id > 0) {
                    toRemoveArr.push(findData.id);
                }
            }
            if (skipQuery) {
                VOD.Util.delNewsMethod(toRemoveArr, findData);
            } else {
                SystemDialog.queryConfirm("确认删除该条新闻么?", function (flag) {
                    if (flag === true) {
                        VOD.Util.delNewsMethod(toRemoveArr, findData);
                    }
                });
            }
        },
        delNewsMethod: function (toRemoveArr, findData) {
            if (toRemoveArr.length == 0) {
                VOD.Util.mergeNewsGridData([], [findData]);
            } else {
                VOD.Dao.delNews({ key: VOD.Dao.settings.taskid, id: toRemoveArr.join(","), status: 2, from_client: true }, function (data) {
                    console.log(JSON.stringify(data));
                    if (data.code == "A00000") {
                        VOD.Plugin.tips("success", data.msg);
                    } else {
                        VOD.Plugin.tips("error", data.msg);
                    }
                    $("button[name=refresh_tab2]").click();
                })
            }
        },
        delAdvert: function (rowId) {
            SystemDialog.queryConfirm("确认删除么?", function (flag) {
                if (flag === true) {
                    var findData = VOD.Config.PageBeanAdvert.findData("index", rowId);
                    if (findData != null) {
                        VOD.Config.PageBeanAdvert.delOne(findData)
                        VOD.Util.updateGridAdvert();
                        VOD.Util.delOne("删除", findData.sTime, findData.eTime);
                    }
                }
            })
        },
        AlterTitle: function (rowId) {
            $("#alter_title-dlg").dialog("open");
            var rowData = VOD.Config.PageBeanNews.findData("regId", rowId);
            var titleArr = JSON.parse(rowData.title);
            $("#alter_title-dlg").find("form").html("");
            var htmlArr = [];
            htmlArr.push('<input name="alter_title_id" type="hidden" value="' + rowId + '" />');
            $.each(titleArr, function (i, element) {
                htmlArr.push('<label><input type="radio" name="alter_title_radio" value="' + element + '" />' + element + '</label>')
            })
            $("#alter_title-dlg").find("form").html(htmlArr.join(""));
        },
        updateNewsFormData: function () {
            var selectedValue = $("input[name=alter_title_radio]:checked").val();
            if (selectedValue == null) {
                return;
            }
            $("input[name=tab3_title]").val(selectedValue);
        },

        updateNewsGridRowData: function () {
            var selectedValue = $("input[name=alter_title_radio]:checked").val();
            if (selectedValue == null) {
                return;
            }
            var elementId = $("input[name=alter_title_id]").val();
            var rowData = VOD.Config.PageBeanNews.findData("regId", elementId);
            if (rowData != null && rowData.showTitle != selectedValue) {
                rowData.showTitle = selectedValue;
                $("#news_list").setRowData(rowData.regId, { title: rowData.title, regId: rowData.regId });
            }
        },
        fromLIstJump: function (index) {
            if (!this.isJumpData(index, 0)) {
                //alert('跳转输入格式错误');
                VOD.Plugin.tips("error", '跳转输入格式错误');
                return false;
            }
            var jumpContent = index + '-jump';
            if ($('.relative').hasClass(jumpContent)) {
                $('#makedImg').scrollTop(0)
                var sTop = $('.' + jumpContent).offset().top - 100;
                $('#makedImg').scrollTop(sTop);
            } else {
                //alert('没有这帧');
                VOD.Plugin.tips("error", '没有这帧');
            }
        },
        initHelp: function () {
            var innerText = "";
            $.each(VOD.Config.HELP_DATA, function (i, data) {
                innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
            })
            $("#help-dlg").find("tbody").html(innerText);
            if ($("#help2-dlg").length > 0) {
                innerText = "";
                $.each(VOD.Config.HELP2_DATA, function (i, data) {
                    innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
                })
                $("#help2-dlg").find("tbody").html(innerText);
            }
        },
        validStart: function () {
            var self = this;
            var settings = VOD.Dao.settings;
            if (VOD.Config.EDIT_MODE_TYPE == 1) {
                var s_time = $('#inputStartTime').val();
                var e_time = $('#inputEndTime').val();
                var checkArr = [];
                checkArr.push({value: s_time.length, error: "请先输入起始时间", type: "gt", other: 0 })
                checkArr.push({value: e_time.length, error: "请先输入结束时间", type: "gt", other: 0 })
                checkArr.push({value: s_time, error: "起始时间格式不正确", type: "date"})
                checkArr.push({value: e_time, error: "结束时间格式不正确", type: "date"})
                checkArr.push({value: s_time, error: "开始时间必须小于结束时间", type: "lt", other: e_time })
                checkArr.push({value: s_time, error: "开始时间不能大于当前时间", type: "lt", other: this.formatDateTimeFormat(new Date()) });
                if (!VOD.Plugin.Validate.batchCheck(checkArr)) {
                    console.log("interrupt checkLiveType checkRepeat")
                    return false;
                }
                settings.period = parseInt((self.dateToNumber(e_time) - self.dateToNumber(s_time)) / 1000);
                settings.today = s_time.replace(/-/g, '').substring(0, 8);
                return parseInt(this.dateToNumber(s_time) / 1000);
            } else if (VOD.Config.EDIT_MODE_TYPE == 2) {
                return true;
            }
            return false;

        },
        dateToNumber: function (dString) {
            var toDate = new Date(dString.replace(/-/g, "/"));
            return toDate.getTime();
        },
        getLineWidth: function () {
            var settings = VOD.Dao.settings;
            var lineWidth = $('.img-content').width();
            var picWidth = $('.relative').width();
            settings.linePicNum = parseInt(lineWidth / picWidth);
        },
        addClearFix: function () {
            var cb = 1;
            var global = VOD.Config.Global;
            var settings = VOD.Dao.settings;
            $('#makedImg').find('.text-center').each(function (k, v) {
                s = '<div class="clearfix breakWord">&nbsp;</div>';
                if (global.smallPic) {
                    if (cb % settings.linePicNum == 0) {
                        $(this).after(s);
                    }
                }
                if (!global.smallPic) {
                    if (cb % settings.linePicNum == 0) {
                        $(this).after(s);
                    }
                }
                cb++;
            })
        },
        dl_click: function (clt) {
            try {
                if (clt == '') {
                    return;
                }
                var Then = new Date();
                var continued_time = Math.round((Then.getTime()) / 1000);
                $.get(clt + "&ct=" + continued_time);
            }
            catch (e) {
                console.log("error", e);
            }
        },
        dl_img_click: function (event, viewTime) {
            VOD.Player.view(viewTime)
        },

        validAddInfo: function (data) {
            var v = true;
            $.each(data, function (message, type) {
                if (type == null || type.length == 0) {
                    VOD.Plugin.tips("error", message + '不存在，请重新输入');
                    v = false;
                    return false;
                }
            });
            return v;
        },
        addInfo: function (data, type) {
            data.sTime = parseInt(  data.sTime );
            data.eTime = parseInt(  data.eTime );
            if (type == 'add') {

                //  html = '<tr class="scorll-to-frame" frame-index="' + data.index + '"><td>' + data.index + '</td><td>' + data.sTime + '</td><td>' + data.eTime + '</td><td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="' + data.title + '">' + data.title + '</div></td><td>' + data.channel + '</td><td>' + data.album + '</td><td>' + data.pic + '</td><td>已生成</td><td><button class="btn btn-info" id="del-' + data.index + '" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'打点\',\'' + data.sTime + '\',\'' + data.eTime + '\');}">删除</button><a style="margin-left:5px;" onClick="reviewOne(\'' + data.sTime + '\',\'' + data.eTime + '\',\'打点\');" class="btn btn-success">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'' + data.sTime + '\');" class="btn btn-success">跳转</a></td></tr>';
                $('#addInfo').html('成功');
                VOD.Config.PageBeanFrame.addNewOne(data);
                VOD.Util.updateGridFrame();
                //   $('#showInfo1').append(html);
            } else {
                //   html = '<tr class="scorll-to-frame" frame-index="' + data.index + '"><td>' + data.index + '</td><td>' + data.sTime + '</td><td>' + data.eTime + '</td><td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="' + data.title + '">' + data.title + '</div></td><td>已生成</td><td><button class="btn btn-info" id="del-' + data.index + '" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'删除\',\'' + data.sTime + '\',\'' + data.eTime + '\');}">删除</button><a style="margin-left:5px;" onClick="reviewOne(\'' + data.sTime + '\',\'' + data.eTime + '\',\'删除\');" class="btn btn-success">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'' + data.sTime + '\');" class="btn btn-success">跳转</a></td></tr>';
                $('#d_addInfo').html('成功');
                //     $('#showInfo2').append(html);
                VOD.Config.PageBeanAdvert.addNewOne(data);
                VOD.Util.updateGridAdvert();
                var advertSource = VOD.Config.PageBeanAdvert.getSource();
                var temp = [];
                var uniqueArr = [];
                $.each(advertSource, function (i, element) {
                    for (var i = element.sTime; i <= element.eTime; i++) {
                        temp.push(i);
                    }
                })
                $.each(temp, function (i, el) { //去重复
                    if ($.inArray(el, uniqueArr) === -1)
                        uniqueArr.push(el);
                });
                VOD.Dao.settings.delList = uniqueArr;
            }
        },
        delOne: function (type, s, e) {
            var arr3 = [];
            var settings = VOD.Dao.settings;
            if (type == '删除' && settings.delList.length) {
                var advertSource = VOD.Config.PageBeanAdvert.getSource();
                $.each(advertSource, function (i, element) {
                    for (var i = element.sTime; i <= element.eTime; i++) {
                        arr3.push(i);
                    }
                })
//                $('#showInfo2').find('tr').each(function () {
//                    var d_stime = parseInt($(this).children().eq(1).text());
//                    var d_etime = parseInt($(this).children().eq(2).text());
//                    for (var i = d_stime; i <= d_etime; i++) {
//                        arr3.push(i);
//                    }
//                })
                var uniqueArr3 = [];
                $.each(arr3, function (i, el) { //去重复
                    if ($.inArray(el, uniqueArr3) === -1)
                        uniqueArr3.push(el);
                });
                settings.delList = uniqueArr3;
            }
        },

        getDataByNum: function (_num) {
            var day = 864000,
                hour = 3600,
                minute = 60,
                base = 0,
                res = '',
                num = _num;
            if (num >= day) {
                base = parseInt(num / day);
                res += String(base);
                num = num - base * day;
            }
            if (num >= hour) {
                base = parseInt(num / hour);
                if (base < 10) {
                    res += '0';
                }
                res += String(base);
                num = num - base * hour;
                res += ':';
            } else {
                res += '00:';
            }
            if (num >= minute) {
                base = parseInt(num / minute);
                if (base < 10) {
                    res += '0';
                }
                res += String(base);
                num = num - base * minute;
                res += ':';
            } else {
                res += '00:';
            }
            if (num >= 0) {
                if (num < 10) {
                    res += '0';
                }
                res += String(num);
            }
            return res;
        },

        //提交删除
        checkStAndEt: function (stime, etime, plusMsg) {
            plusMsg = plusMsg || "";
            var checkArr = [];
            checkArr.push({value: stime, error: plusMsg + "起始帧有误,必须为数字类型", type: "number"})
            checkArr.push({value: etime, error: plusMsg + "结束帧有误,必须为数字类型", type: "number"})
            checkArr.push({value: parseInt(stime), error: plusMsg + "起始帧不能大于结束帧", type: "le", other: parseInt(etime)  })
            return VOD.Plugin.Validate.batchCheck(checkArr)
        },

        del_submit: function () {
            var d_sTime = $('input[name=d_sTime]').val();
            var d_eTime = $('input[name=d_eTime]').val();
            var d_title = $('input[name=d_videoName]').val();
            //////////////////////////////////////////////////////////
            var d_type = $('input[name=d_imgType]').val();
            //////////////////////////////////////////////////////////
            $('#d_addInfo').attr('disabled', 'disabled');
            var data = {
                '起始帧': d_sTime,
                '结束帧': d_eTime,
                '标题': d_title
            };
            if (!this.checkStAndEt(d_sTime, d_eTime)) {
                console.log("interrupt checkLiveType checkRepeat")
                return false;
            }
            if (!this.validAddInfo(data)) {
                return false;
            }
            var dataSubmit = {
                'index': VOD.Dao.settings.index,
                'sTime': d_sTime,
                'eTime': d_eTime,
                'title': d_title,
                'channel': '',
                'album': '',
                'pic': ''
            }
            VOD.Config.Global.d_sty2Data.push(dataSubmit);
            this.addInfo(dataSubmit, 'del');
            $('input[name=d_sTime]').val('');
            $('input[name=d_eTime]').val('');
            VOD.Dao.settings.index++;
            VOD.AccurateFrame.adTipRemove(); // 广告左右标识删除
            return true;
        },

        //新闻拆条发布
        news_submit: function () {
            var settings = VOD.Dao.settings;
            var paramsData = VOD.Dao.getParamsData();
            var global = VOD.Config.Global;
            if (settings.taskid < 1.) {
                VOD.Plugin.tips("error", '任务ID为空,不能提交!');
                return false;
            }

            var sTime = $('input[name=tab3_inpoint]').val(),
                eTime = $('input[name=tab3_outpoint]').val(),
                title = $('input[name=tab3_title]').val(),
                channel = $('input[name=tab3_categoryName]').suggest("getValue");
            var cpOption = $('#tab3_cp').children('option:selected');
            var album = $('input[name=tab3_albumName]').val(),
                pic = $('input[name=tab3_imageId]').val() ? $('input[name=tab3_imageId]').val() : sTime,
                data = {
                    '起始帧': sTime,
                    '结束帧': eTime,
                    '标题': title,
                    '频道': channel
                },
                dataSubmit = {
                    'index': settings.index,
                    'sTime': sTime,
                    'eTime': eTime,
                    'title': title,
                    'channel': channel,
                    'album': album,
                    'pic': pic
                },
                toLego = true,

                priority = $('input[name=tab3_priority]:checked').val(), //优先级
                video_dpi = $('input[name=tab3_video_dpi]:checked').val(), //分辨率
                uid = cpOption.attr("uid"), //表示ugc用户id
                partnerId = cpOption.attr("partnerId"), //表示合作方id
                episodeType = cpOption.attr("episodeType"); //取值为0或1,1表示为ugc视频，0为普通ppc视频
            uid = !uid ? "" : uid;
            partnerId = !partnerId ? "" : partnerId;
            episodeType = !episodeType ? "" : episodeType;
            var albumId = '';
            if (album) {
                albumId = $('input[name=albumName]').suggest("getValue") || "";
                //  $('input[name=albumId]').val();
            }
            if (!this.checkStAndEt(sTime, eTime)) {
                return false;
            }
            var checkArr = [];
            checkArr.push({value: pic, error: "封面格式有误,必须为数字类型", type: "number"})
            var numTime = $('#picNum').text();
            checkArr.push({value: parseInt(eTime), error: "结束帧不存在,不能提交", type: "le", other: parseInt(numTime)  })
            if (!VOD.Plugin.Validate.batchCheck(checkArr)) {
                console.log("interrupt checkLiveType checkRepeat")
                return false;
            }
            $('#tab3_submit').attr('disabled', 'disabled');
            if (!toLego) {
                return;
            }
            if (!this.validAddInfo(data)) {
                return false;
            }
            if (!VOD.AccurateFrame.isMarkedFrame(parseInt(eTime)) && !VOD.AccurateFrame.getAccurateFrame().endSetted) {
                //alert("请在片尾使用精确化裁剪工具，快捷键Q");
                VOD.Plugin.tips("error", "请在出点使用精确化裁剪工具，快捷键Q");
                return false;
            }

            //去除删除部分
            VOD.Player.splitData(sTime, eTime, true);
            //console.log(subData);
            if (!settings.subData.length) {
                //alert('该条打了删除，不能再打拆条!');
                VOD.Plugin.tips("error", '该条打了删除，不能再打拆条!');
                return false;
            }

            var p_vid = 0;
            var p_albumId = $('input[name=tab3_albumName]').suggest("getValue") || "";

            var rightIdentification = 0,
                options = {};

            var delAdStr = "";
            var adLibList = settings.adLibList;
            var advertSource = VOD.Config.PageBeanAdvert.getSource();
            $.each(advertSource, function (i, element) {
                var s = $('.' + element.sTime + '-jump').attr("id").split("-")[1],
                    e = $('.' + element.eTime + '-jump').attr("id").split("-")[1];


                if (delAdStr != "")
                    delAdStr += ',';

                delAdStr += '0/' + s + '_0/' + e

                for (var dj in adLibList) {
                    if (adLibList[dj].s <= s && adLibList[dj].e >= s) {
                        if (adLibList[dj].s == s && adLibList[dj].e == e) {
                            rightIdentification++;
                        }
                        break;
                    }
                }
            })

            var adLibListLen = 1;
            if (adLibList.length !== 0) {
                adLibListLen = adLibList.length;
            }

            options.from_client = true;  //绕过鉴权
            options.score = rightIdentification / adLibListLen * 10; //  打分是在1~10分之前包括小数
            options.func = "modify_ablum";

            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.modifyUrl,
                data: {"channel_id": paramsData._channel_id, "ablum_id": p_albumId, "func": options.func, "score": options.score},
                success: function (res) {
                    console.log("$.ajax 842 success");
                    console.log(res);
                },
                dataType: "json",
                error: function () {
                    //alert('网络错误,请稍后再广告评分入库！');
                    VOD.Plugin.tips("error", '网络错误,请稍后再广告评分入库！');
                }
            });

//////////////////////////////////////////end  todo 还待优化 //////////////////////////////////////////////////////
            var dataJson = {
                'videoId': p_vid,
                'priority': priority,
                'albumName': album,
                'videoName': title,
                'categoryId': channel,
                'albumId': p_albumId,
                'reTranscodeConfirm': VOD.Util.getReTranscodeConfirmVal(),
                'freeType': paramsData.freeType
            };
            if ($("#locationDiv").is(":visible")) {
                dataJson.locationCategory = $("input[name=location]").suggest("getValue");
            }
            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.redirect,
                timeout: 10000,
                data: {"request": JSON.stringify({url: VOD.Constant.thirdUrl_legoProgramIdUrl, type: "post", params: {
                    data: JSON.stringify(dataJson)
                }, needCookie: true}), timeSign: new Date().getTime()},
                success: function (res) {
                    if (res.code != 'A00000') {
                        //alert(res.msg);
                        VOD.Plugin.tips("error", res.msg);
                    } else {
                        var programId = res.data.programId;
                        if (!programId) {
                            //alert('乐高返回的programId为空!');
                            VOD.Plugin.tips("error", '乐高返回的programId为空!');
                            return false;
                        }

                        var newPA = {
                            title: title,
                            cat: channel,
                            alb: albumId,
                            enableClound: VOD.Util.getEnableCloundVal(),
                            priority: priority,
                            video_dpi: video_dpi,
                            uid: uid,
                            partnerId: partnerId,
                            episodeType: episodeType
                        }

                        //提交数据给刘之红
                        if (VOD.Util.postData(settings.subData, newPA, pic, programId, dataSubmit)) {
//////////////////////////制作数据统计///////////////////////////////////////////
/////////////////////////////end//////////////////////////////////////////////////////
                            //alert('打点成功');
                            VOD.Plugin.tips("success", '打点成功');
                            VOD.AccurateFrame.doReset();
                            VOD.Util.clearHighLight();
                            return true;
                        }
                    }
                },
                dataType: "json",
                error: function (XMLHttpRequest, status) {
                    //alert('网络错误,请稍后再提交！');
                    if (status == 'timeout') {
                        ajaxTimeoutTest.abort();
                        VOD.Plugin.tips("error", '接口/peditor/submit调用超时10秒未响应！请联系乐高相关负责人员！');
                    } else {
                        VOD.Plugin.tips("error", '网络错误,请稍后再提交！');
                    }
                    $('#tab3_submit').removeAttr('disabled').html('提交');
                }
            });
        },

        //提交拆条
        dot_submit: function () {
            var settings = VOD.Dao.settings;

            var paramsData = VOD.Dao.getParamsData();
            var global = VOD.Config.Global;
            if (settings.taskid < 1.) {
                VOD.Plugin.tips("error", '任务ID为空,不能提交!');
                return false;
            }

            var sTime = $('input[name=sTime]').val(),
                eTime = $('input[name=eTime]').val(),
                title = $('input[name=videoName]').val(),
                channel = $('input[name=categoryName]').suggest("getValue");
            var cpOption = $('#cp').children('option:selected');
            var album = $('input[name=albumName]').val(),
                pic = $('input[name=imageId]').val() ? $('input[name=imageId]').val() : sTime,
                fantasyTitle = $('textarea[name=fantasyTitle]').val() ? $('textarea[name=fantasyTitle]').val() : "",
                data = {
                    '起始帧': sTime,
                    '结束帧': eTime,
                    '标题': title,
                    '频道': channel
                },
                dataSubmit = {
                    'index': settings.index,
                    'sTime': sTime,
                    'eTime': eTime,
                    'title': title,
                    'channel': channel,
                    'album': album,
                    'pic': pic
                },
                toLego = true,

                priority = $('input[name=priority]:checked').val(), //优先级
                video_dpi = $('input[name=video_dpi]:checked').val(), //分辨率
                uid = cpOption.attr("uid"), //表示ugc用户id
                partnerId = cpOption.attr("partnerId"), //表示合作方id
                episodeType = cpOption.attr("episodeType"); //取值为0或1,1表示为ugc视频，0为普通ppc视频
            uid = !uid ? "" : uid;
            partnerId = !partnerId ? "" : partnerId;
            episodeType = !episodeType ? "" : episodeType;
            var albumId = '';
            if (album) {
                albumId = $('input[name=albumName]').suggest("getValue") || "";
                //  $('input[name=albumId]').val();
            }

            if (!this.checkStAndEt(sTime, eTime)) {
                return false;
            }
            var checkArr = [];
            checkArr.push({value: pic, error: "封面格式有误,必须为数字类型", type: "number"})
            var numTime = $('#picNum').text();
            checkArr.push({value: parseInt(eTime), error: "结束帧不存在,不能提交", type: "le", other: parseInt(numTime)  })
            if (!VOD.Plugin.Validate.batchCheck(checkArr)) {
                console.log("interrupt checkLiveType checkRepeat")
                return false;
            }
            $('#addInfo').attr('disabled', 'disabled');

            if (!toLego) {
                return;
            }
            if (!this.validAddInfo(data)) {
                return false;
            }

            if (!VOD.AccurateFrame.getAccurateFrame().endSetted) {
                //alert("请在片尾使用精确化裁剪工具，快捷键Q");
                VOD.Plugin.tips("error", "请在片尾使用精确化裁剪工具，快捷键Q");
                return false;
            }

            //去除删除部分
            VOD.Player.splitData(sTime, eTime, true);
            //console.log(subData);
            if (!settings.subData.length) {
                //alert('该条打了删除，不能再打拆条!');
                VOD.Plugin.tips("error", '该条打了删除，不能再打拆条!');
                return false;
            }

//            if (settings.videonameArr.length) {
//                var exist = false;
//                for (var i in settings.videonameArr) {
//                    if (settings.videonameArr[i] == title) {
//                        exist = true;
//                    }
//                }
//                if (!exist) {
//                    //alert('提交失败，标题不存在!');
//                    VOD.Plugin.tips("error", '提交失败，标题不存在!');
//                    return false;
//                }
//            }

            //提交数据到乐高
            // var p_vid = $('input[name=videoId]').val() ? $('input[name=videoId]').val() : 0;
            var p_vid = $('input[name=videoName]').suggest("getValue") || 0;
            var p_albumId = $('input[name=albumName]').suggest("getValue") || "";
            var videotype = $('input[name=videotype]:checked').val();
            if (videotype == -1) {
                p_vid = 0;
            }

///////////////////////////////   评分   ////////////////////////////////////
            var rightIdentification = 0,
                options = {};

            var delAdStr = "";
            var adLibList = settings.adLibList;
            var advertSource = VOD.Config.PageBeanAdvert.getSource();
            $.each(advertSource, function (i, element) {
                var s = $('.' + element.sTime + '-jump').attr("id").split("-")[1],
                    e = $('.' + element.eTime + '-jump').attr("id").split("-")[1];


                if (delAdStr != "")
                    delAdStr += ',';

                delAdStr += '0/' + s + '_0/' + e

                for (var dj in adLibList) {
                    if (adLibList[dj].s <= s && adLibList[dj].e >= s) {
                        if (adLibList[dj].s == s && adLibList[dj].e == e) {
                            rightIdentification++;
                        }
                        break;
                    }
                }
            })

            var adLibListLen = 1;
            if (adLibList.length !== 0) {
                adLibListLen = adLibList.length;
            }

            options.from_client = true;  //绕过鉴权
            options.score = rightIdentification / adLibListLen * 10; //  打分是在1~10分之前包括小数
            options.func = "modify_ablum";


            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.modifyUrl,
                data: {"channel_id": paramsData._channel_id, "ablum_id": p_albumId, "func": options.func, "score": options.score},
                success: function (res) {
                    console.log("$.ajax 842 success");
                    console.log(res);
                },
                dataType: "json",
                error: function () {
                    //alert('网络错误,请稍后再广告评分入库！');
                    VOD.Plugin.tips("error", '网络错误,请稍后再广告评分入库！');
                }
            });

//////////////////////////////////////////end  todo 还待优化 //////////////////////////////////////////////////////

            var dataJson = {
                'videoId': p_vid,
                'priority': priority,
                'albumName': album,
                'videoName': title,
                'categoryId': channel,
                'albumId': p_albumId,
                'reTranscodeConfirm': VOD.Util.getReTranscodeConfirmVal(),
                'freeType': paramsData.freeType
            };
            if ($("#locationDiv").is(":visible")) {
                dataJson.locationCategory = $("input[name=location]").suggest("getValue");
            }
            if (videotype == -1) {
                dataJson.fantasyTitle = fantasyTitle;
            }
            // settings.videonameArr = [];

            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.redirect,
                timeout: 10000,
                data: {"request": JSON.stringify({url: VOD.Constant.thirdUrl_legoProgramIdUrl, type: "post", params: {
                    data: JSON.stringify(dataJson)
                }, needCookie: true}), timeSign: new Date().getTime()},
                success: function (res) {
                    if (res.code != 'A00000') {
                        //alert(res.msg);
                        VOD.Plugin.tips("error", res.msg);
                    } else {
                        var programId = res.data.programId;
                        if (!programId) {
                            //alert('乐高返回的programId为空!');
                            VOD.Plugin.tips("error", '乐高返回的programId为空!');
                            return false;
                        }

                        var newPA = {
                            title: title,
                            cat: channel,
                            alb: albumId,
                            enableClound: VOD.Util.getEnableCloundVal(),
                            priority: priority,
                            video_dpi: video_dpi,
                            uid: uid,
                            partnerId: partnerId,
                            episodeType: episodeType
                        }

                        //提交数据给刘之红
                        if (VOD.Util.postData(settings.subData, newPA, pic, programId, dataSubmit)) {
//////////////////////////制作数据统计///////////////////////////////////////////
                            var sSrc = $("#img-" + sTime).attr("src"),
                                eSrc = $("#img-" + eTime).attr("src");

                            var s_fp_pos = sSrc.lastIndexOf('/') + 1,
                                s_fp_time = sSrc.substr(VOD.Config.Global.fp_pos, 10),
                                e_fp_pos = eSrc.lastIndexOf('/') + 1,
                                e_fp_time = eSrc.substr(VOD.Config.Global.fp_pos, 10);

                            var seconds = (parseInt(e_fp_time) - parseInt(s_fp_time));

                            $.each(global.d_sty2Data, function (n, adData) {
                                var adStartTime = adData.sTime, adEndTime = adData.eTime;
                                if (sTime < adStartTime && eTime > adEndTime) {

                                    var sSrc = $("#img-" + adStartTime).attr("src"),
                                        ads_fp_pos = sSrc.lastIndexOf('/') + 1,
                                        ads_fp_time = sSrc.substr(ads_fp_pos, 10),
                                        eSrc = $("#img-" + adEndTime).attr("src"),
                                        ade_fp_pos = eSrc.lastIndexOf('/') + 1,
                                        ade_fp_time = eSrc.substr(ade_fp_pos, 10);
                                    var ad_seconds = (parseInt(ade_fp_time) - parseInt(ads_fp_time));
                                    seconds = seconds - ad_seconds;
                                }
                            });

                            VOD.Util.dl_click("/api/st?bs=1&st=1&prid=" + programId
                                    + "&pr_name=" + encodeURIComponent(newPA.title)
                                    + "&pr_mins=" + seconds
                                    + "&cname=" + $('input[name=categoryName]').val()
                                    + "&u=" + VOD.Util.getUserName()
                                    + "&cp=" + paramsData._channel_name_str
                                    + "&bt=" + new Date(parseInt(s_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss")
                                    + "&et=" + new Date(parseInt(e_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss")
                                    + "&dst=" + new Date().format("yyyy-MM-dd hh:mm:ss")
                                    + "&ablum_name=" + album
                                    + "&s_a_dot=" + ""                   //广告开始
                                    + "&s_m_dot=" + sTime					//打点手动开始
                                    + "&e_a_dot=" + ""						//广告结束
                                    + "&e_m_dot=" + eTime					//打点手动结束
                                    + "&ad_info=" + delAdStr
                            );

//////////////////////////OCR统计///////////////////////////////////////////
                            if (!$("#ocr").hasClass("disabled")) {
                                var ocrTitle = VOD.Config.Global.statisticOcrTitle;
                                VOD.Config.Global.statisticOcrTitle = "";
                                VOD.Util.dl_click("/api/st?bs=1&st=3&programId=" + programId
                                        + "&programName=" + encodeURIComponent(newPA.title)
                                        + "&channelId=" + paramsData._channel_id
                                        + "&channelName=" + paramsData._channel_name_str
                                        + "&categoryName=" + $('input[name=categoryName]').val()
                                        + "&ocrTitle=" + encodeURIComponent(ocrTitle)
                                        + "&userTitle=" + encodeURIComponent(newPA.title)
                                        + "&user=" + VOD.Util.getUserName()
                                );
                            }
//////////////////////////长视频智能分析统计///////////////////////////////////////////
// sty2Data 缓存sty2数据
// d_sty2Data 缓存提交后的广告头和尾

                            var headerCompleteNumbers = headerIncompleteNumbers = headerFaultNumbers = 0,
                                lastCompleteNumbers = lastIncompleteNumbers = lastFaultNumbers = 0,
                                adCompleteNumbers = adIncompleteNumbers = adFaultNumbers = 0;

// 计算广告智能分析正确数
                            var eq_sTime, eq_eTime,
                                headerSty2Index, headerSty2Length, headerListIndex,
                                lastSty2Index, lastSty2Length, lastListIndex,
                                gtSty2Flag, ltSty2Flag;
                            var sty2DataList = global.sty2Data.list;
                            if (global.channelInfo.length == 0 || global.channelInfo[0].sty2 == 1) {

                                $.each(global.d_sty2Data, function (n, adData) {
                                    var sVid = $('.' + adData.sTime + '-jump').attr("id").split("-")[1],
                                        eVid = $('.' + adData.eTime + '-jump').attr("id").split("-")[1];
                                    console.log("sty2DataList ,length ", sty2DataList.length);
                                    $.each(sty2DataList, function (i, item) {
                                        console.log("itemvideo_list ,length ", (item.video_list == null), item.video_list.length);
                                        $.each(item.video_list, function (j, sty2Id) {
                                            if (item.type == VOD.Config.adLib) {
                                                var length = item.video_list.length;
                                                if (sVid == sty2Id) {
                                                    headerSty2Index = i;
                                                    headerListIndex = j;
                                                    headerSty2Length = length;
                                                    eq_sTime = sty2Id;
                                                } else if (eVid == sty2Id) {
                                                    lastSty2Index = i;
                                                    lastListIndex = j;
                                                    lastSty2Length = length;
                                                    eq_eTime = sty2Id;
                                                }
                                                if (j == 0 && sVid < sty2Id) {
                                                    ltSty2Flag = true;
                                                }
                                                if (j == length - 1 && eVid > sty2Id) {
                                                    gtSty2Flag = true;
                                                }
                                            }
                                        });
                                    });


                                    if (eq_sTime == null && eq_eTime == null) {
                                        if (ltSty2Flag && gtSty2Flag) {
                                            adIncompleteNumbers++;
                                        } else {
                                            adFaultNumbers++;
                                        }

                                    } else if (eq_sTime == null || eq_eTime == null) {
                                        adIncompleteNumbers++;
                                    } else if (eq_sTime != null && eq_eTime != null) {
                                        var adRound = eq_eTime - eq_sTime + 1;
                                        if (headerSty2Index == lastSty2Index && adRound == headerSty2Length) {
                                            adCompleteNumbers++;
                                        } else if (headerSty2Index == lastSty2Index && adRound != headerSty2Length) {

                                            adIncompleteNumbers++;
                                        } else if (headerSty2Index != lastSty2Index) {
                                            if (headerListIndex != 0 || lastListIndex != lastSty2Length - 1) {
                                                adIncompleteNumbers++;
                                            } else {
                                                var index = headerSty2Index;
                                                var flag = true;
                                                while (flag) {
                                                    if (index == lastSty2Index) {
                                                        adCompleteNumbers++;
                                                        flag = false;
                                                    } else {
                                                        var videoList = sty2DataList[index].video_list;
                                                        var nextVideoList = sty2DataList[index + 1].video_list;
                                                        if ((nextVideoList[0] - videoList[videoList.lenth - 1]) >= 2) {
                                                            adIncompleteNumbers++;
                                                            flag = false;
                                                        }
                                                    }
                                                    index++;
                                                }
                                            }
                                        }
                                    }

                                });
// 广告智能分析提交数请空
                                global.d_sty2Data = [];
                                headerSty2Index = null;
                                eq_sTime = null;
                                eq_eTime = null;

                                sVid = $('.' + sTime + '-jump').attr("id").split("-")[1];
                                eVid = $('.' + eTime + '-jump').attr("id").split("-")[1];
// 计算片头和片尾正确数
                                console.log("sty2DataList ,length ", sty2DataList.length);
                                $.each(sty2DataList, function (i, item) {
                                    console.log("itemvideo_list ,length ", (item.video_list == null), item.video_list.length);
                                    $.each(item.video_list, function (j, sty2Id) {
                                        if (item.type == VOD.Config.adLibHead) {
                                            if (sVid == sty2Id) {
                                                headerSty2Index = j;
                                                eq_sTime = sty2Id;
                                            }
                                        }
                                        if (item.type == VOD.Config.adLibTail) {
                                            if (eVid == sty2Id) {
                                                lastSty2Index = j;
                                                lastSty2Length = item.video_list.length;
                                                eq_eTime = sty2Id;
                                            }
                                        }
                                    });
                                });

                                if (eq_sTime == null) {
                                    headerFaultNumbers++;
                                } else if (eq_sTime != null && headerSty2Index == 0) {
                                    headerCompleteNumbers++;
                                } else {
                                    headerIncompleteNumbers++;
                                }

                                if (eq_eTime == null) {
                                    lastFaultNumbers++;
                                } else if (eq_eTime != null && lastSty2Index == lastSty2Length - 1) {
                                    lastCompleteNumbers++;
                                } else {
                                    lastIncompleteNumbers++;
                                }

                                VOD.Util.dl_click("/api/st?bs=1&st=2&channelId=" + paramsData._channel_id
                                        + "&channelName=" + paramsData._channel_name_str
                                        + "&channelCode=" + paramsData.channel_name
                                        + "&programId=" + programId
                                        + "&programName=" + encodeURIComponent(newPA.title)
                                        + "&categoryName=" + $('input[name=categoryName]').val()
                                        + "&albumName=" + album
                                        + "&programTime=" + seconds
                                        + "&headerCompleteNumbers=" + headerCompleteNumbers
                                        + "&headerIncompleteNumbers=" + headerIncompleteNumbers
                                        + "&headerFaultNumbers=" + headerFaultNumbers
                                        + "&lastCompleteNumbers=" + lastCompleteNumbers
                                        + "&lastIncompleteNumbers=" + lastIncompleteNumbers
                                        + "&lastFaultNumbers=" + lastFaultNumbers
                                        + "&adCompleteNumbers=" + adCompleteNumbers
                                        + "&adIncompleteNumbers=" + adIncompleteNumbers
                                        + "&adFaultNumbers=" + adFaultNumbers
                                        + "&user=" + VOD.Util.getUserName()
                                );
                            }
/////////////////////////////end//////////////////////////////////////////////////////

                            //alert('打点成功');
                            VOD.Plugin.tips("success", '打点成功');
                            VOD.AccurateFrame.fgTipRemove();
                            return true;
                        }
                    }
                },
                dataType: "json",
                error: function (XMLHttpRequest, status) {
                    //alert('网络错误,请稍后再提交！');
                    if (status == 'timeout') {
                        ajaxTimeoutTest.abort();
                        VOD.Plugin.tips("error", '接口/peditor/submit调用超时10秒未响应！请联系乐高相关负责人员！');
                    } else {
                        VOD.Plugin.tips("error", '网络错误,请稍后再提交！');
                    }
                    $('#tab3_submit').removeAttr('disabled').html('提交');
                }
            });

        },
        // 获取字符串长度
        subCharacterLength: function (str, charLength) {
            var titleReg = new RegExp("[\\u4E00-\\u9FFF]");
            var countLength = 0;
            var indexCount = 0;
            var tmpLength = 0;
            for (var i = 0, l = str.length; i < l; i++) {
                // 0-127 ASCII char
                // 128-255 ASCII expand char
                if (str.charCodeAt(i) > 255) {
                    tmpLength = 2;
                } else {
                    tmpLength = 1;
                }
                if (countLength + tmpLength > charLength) {
                    break;
                }
                indexCount++;
                countLength += tmpLength;
            }
            return str.substr(0, indexCount);
        },

        // 填加背景色
        addBackgroundColor: function (options) {
            var defaults = {
                st: 0,
                et: 0,
                color: '',
                removeColor: ''
            };
            options = $.extend({}, defaults, options);

            for (i = options.st; i <= options.et; i++) {
                if (!options.removeColor) {
                    $('#img-' + i).addClass(options.color);
                } else {
                    $('#img-' + i).removeClass(options.color);
                }
            }
        },

        postData: function (list, newPA, imageId, programId, addData) {
            var sList = '[' + list.join(",") + "]";
            var paramsData = VOD.Dao.getParamsData();
            var settings = VOD.Dao.settings;
            var accurateFrame = VOD.AccurateFrame.getAccurateFrame();
            var dotData = VOD.Dao.getDotData();
            var pData = {
                'title': newPA.title,
                'categoryId': newPA.cat,
                'albumId': newPA.alb,
                'code': paramsData.channel_name,
                'programId': programId,
                'userId': VOD.Util.getUserId() + "",
                'from_client': true,
                'key': settings.taskid,
                'list': sList,
                'imageId': imageId,
                'head': accurateFrame.head,
                'end': accurateFrame.end,
                'priority': newPA.priority,
                'video_dpi': newPA.video_dpi,
                'uid': newPA.uid,
                'partnerId': newPA.partnerId,
                'episodeType': newPA.episodeType,
                'enableClound': newPA.enableClound
            };
            VOD.AccurateFrame.doReset();
            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: dotData.dotUrl,
                data: pData,
                success: function (data) {
                    if (data.error != 0) {
                        VOD.Plugin.tips("error", data.error);
                        return false;
                    } else {
                        if (VOD.Util.isTab3Show()) {
                            $("#tab3_submit").html('成功');
                            $("li[aria-controls=tab3]").hide();
                            $("#tab3").hide();
                            var elementId = $("span[name=tabName]").html().replace(/序号|发布/g, "");
                            $("#navDiv").tabs({active: 1});
                            VOD.Util.delNews(elementId, true);
                        } else {
                            $('#addInfo').html('成功');
                            $('#cForm').find('input[type=text]').each(function () {
                                if ($(this).attr('name') == 'albumName' || $(this).attr('name') == 'categoryName' || $(this).attr('name') == 'location') {

                                }
                                else {
                                    $(this).val('');
                                }
                            });
                            $('textarea[name=desc]').val('');
                            $('textarea[name=fantasyTitle]').val('');
                        }
                        VOD.Util.addInfo(addData, 'add');
                        settings.index++;
                        return true;
                    }
                },
                dataType: "json",
                error: function () {
                    VOD.Plugin.tips("error", '编码服务器网络错误,请稍后再提交！');
                    $('#addInfo').removeAttr('disabled').html('提交');
                }
            });
            return true;
        },
        doReview: function (sTime, eTime, deleteFlag) {
            var data = {
                '起始帧': sTime,
                '结束帧': eTime
            };
            if (!VOD.Util.validAddInfo(data)) {
                return false;
            }
            if (parseInt(sTime) > parseInt(eTime)) {
                VOD.Plugin.tips("error", '起始帧不能大于结束帧');
                return false;
            }
            var numTime = $('#picNum').text();
            if (parseInt(eTime) >= parseInt(numTime)) {
                VOD.Plugin.tips("error", '结束帧不存在,不能预览');
                return false;
            }
            VOD.Player.splitData(sTime, eTime, deleteFlag); //去除删除部分
            VOD.Player.review();
        },

        getReTranscodeConfirmVal: function () {
            if ($('input[name=reTranscodeConfirm]').prop('checked')) {
                return 1;
            } else {
                return 0;
            }
        },
        getEnableCloundVal: function () {
            if ($('input[name=enableClound]').prop('checked')) {
                return 0;
            } else {
                return 1;
            }
        },
        getUserId: function () {
            return auth.baseInfo.authInfo.uid;
        },
        getUserName: function () {
            return auth.baseInfo.authInfo.userName;
        },

        /**
         * 限制输入框中字符个数，一个汉字相当于两个字符，wordCount是最多允许的汉字个数
         * @param  {jquery  object}  $des  限制字符个数的输入框
         * @param  {Number}  wordCount     允许输入的最多字字符数（一个汉字等于两个字符）
         * @param  {Boolean} isFilterChars 是否过滤输入内容，true过滤，false或undefined不过滤
         * @param  {Array}  filterChars    需要过滤的字符集，如['$','.']，意为全局过滤 $ *                                 和 .
         */
        limitWordCount: function ($des, charCount, isFilterChars, filterChars, bindHandler) {
            var self = this;
            charCount = charCount || 450;
            var t = function (textarea) {
                var $textarea = $(textarea);
                var text = $textarea.val();
                if (isFilterChars) {
                    text = Com.string.filterSpecialChars(text, filterChars);
                    $textarea.val(text);
                }
                var length = Com.string.getStrLength(text);
                if (length > charCount) {
                    $textarea.val(self.subCharacterLength(text, charCount));
                }
                text = $textarea.val();
                length = Com.string.getStrLength(text);
                if (bindHandler == null) {
                    $textarea.parent().find('span.leftWordsCount').text(charCount - length);
                } else {
                    bindHandler(charCount - length);
                }
            };
            $des.bind({
                input: function () {
                    //   console.log("input handler ")
                    t(this);
                },
                propertychange: function () {
                    //    console.log("propertychange handler ")
                    t(this);
                },
                change: function () {
                    //  console.log("change handler ")
                    t(this);
                },
                focusout: function () {
                    //  console.log("focusout handler ")
                    setTimeout(function () {
                        t($des)
                    }, 100);
                },
                keyup: function () {
                    //   console.log("keyup handler ")
                    t(this);
                }
            });
            $des.keyup();
        },

        binSearchOcrTitle: function (start, end) {
            return this.binSearchTitle(VOD.Dao.settings.g_ocrList, start, end)
        },
        binSearchAcrTitle: function (start, end) {
            return this.binSearchTitle(VOD.Dao.settings.g_acrList, start, end)
        },
        binSearchTitle: function (arr, start, end) {
            var titleList = [];
            var tmp = [];
            var len = arr.length;
            if (len) {
                for (var i in arr) {
                    if (start >= arr[i]['first'] && start <= arr[i]['last'] || arr[i]['first'] >= start && arr[i]['last'] <= end || end >= arr[i]['first'] && end <= arr[i]['last']) {
                        tmp[arr[i]['title']] = i; // 去重复
                    }
                }
                for (var j in tmp) {
                    titleList.push(j);
                }
            }
            return titleList;
        },
        updateGridAdvert: function () {
            $('#advert_list').clearGridData();
            $('#advert_list')[0].addJSONData(VOD.Config.PageBeanAdvert.getCur())
        },
        updateGridFrame: function () {
            $('#frame_list').clearGridData();
            $('#frame_list')[0].addJSONData(VOD.Config.PageBeanFrame.getCur())
        },
        updateGridNews: function (object) {
            if (object != null) {
                var findData = VOD.Config.PageBeanNews.findData("regId", object.id);
                for (var key in object) {
                    if (key != "id" && findData.hasOwnProperty(key)) {
                        findData[key] = object[key];
                    }
                }
                $('#news_list').setRowData(object.id, object);
            }
        },
        recoverTab3: function (key, lastData) {
            switch (key) {
                case "st":
                    $("input[name=tab3_inpoint]").val(lastData.st)
                    break;
                case "et":
                    $("input[name=tab3_outpoint]").val(lastData.et)
                    break;
                case "pic":
                    $("input[name=tab3_imageId]").val(lastData.pic)
                    break;

            }
        },
        updateTab3Check: function (object) {
            var numTime = $('#picNum').text();
            var lastData = VOD.NewsHighlight.getLastOption();
            if (object.value.length == 0) {
                this.recoverTab3(object.key, lastData)
                return;
            }
            if (isNaN(object.value)) {
                this.recoverTab3(object.key, lastData)
                return;
            }

            object.value = parseInt(object.value);
            VOD.NewsHighlight.setNewOption(object);
        },
        updateTab3Form: function (object) {
            if (!this.isTab3Show()) {
                return;
            }
            if (object != null) {
                var findData = VOD.Config.PageBeanNews.findData("regId", object.id);
                for (var key in object) {
                    if (key != "id" && findData.hasOwnProperty(key)) {
                        switch (key) {
                            case "sTime":
                                $("input[name=tab3_inpoint]").val(object[key]);
                                break;
                            case  "eTime":
                                $("input[name=tab3_outpoint]").val(object[key]);
                                break;
                            case "pic":
                                $("input[name=tab3_imageId]").val(object[key]);
                                $("#cover_img").attr("src", $("#img-" + object[key]).attr("src"));
                                break;
                        }
                    }
                }

            }
        },
        updateInfoComplete: function (endTime, infoNum) {
            var checkTime = new Date().getTime() - 600000;
            var isOld = endTime < this.formatDateTimeFormat(new Date(checkTime));
            var infostr = "";
            if (!isOld) {
                infostr = VOD.Config.INFO_UN_COMPLETE
            } else {
                infostr = infoNum == 0 ? VOD.Config.INFO_COMPLETE : VOD.Config.INFO_COMPLETE_WAIT_DO;
            }
            $("a[action-name=info_complete]").html(infostr.replace("N", infoNum));
        },

        updateObjectData: function (newData, oldData) {
            for (var key in newData) {
                if (oldData.hasOwnProperty(key)) {
                    oldData[key] = newData[key];
                }
            }
        },
        isTab2Show: function () {
            return $("li[aria-controls=tab2]").attr("aria-selected") == "true"
        },
        isTab3Show: function () {
            return $("li[aria-controls=tab3]").attr("aria-selected") == "true"
        },
        doQuickAdd: function () {
            VOD.Dao.settings.reg_last_id++;
            var newObj = { title: "[]", sTime: 0, eTime: 1, pic: 0, id: 0, regId: VOD.Dao.settings.reg_last_id, checked: false };
            VOD.Config.PageBeanNews.addNewOne(newObj);
            $("#news_list")[0].addJSONData(VOD.Config.PageBeanNews.getCur());
            VOD.Util.doNewsGridScroll(newObj.regId);
        },
        doRowSelected: function (element) {
            var tempChild = VOD.Config.PageBeanNews.findData("regId", parseInt(element.value));
            tempChild.checked = $(element).is(":checked");
        },
        doSelectedAll: function (flag) {
            var elementArr = $("#news_list").find("input[type=checkbox]");
            $.each(elementArr, function (i, element) {
                if ($(element).is(":checked") == !flag) {
                    $(element).click();
                }
            })
        },

        doQuickMerge: function () {
            var selElementArr = $("#news_list").find("input[type=checkbox]:checked");
            var childArr = [];
            var tempChild = null;
            $.each(selElementArr, function (i, elem) {
                tempChild = VOD.Config.PageBeanNews.findData("regId", parseInt(elem.value));
                childArr.push(tempChild);
            })
            childArr.sort(VOD.Config.SORT_RULE.asc_news_sTime);
            if (childArr.length == 1) {
                return;
            }
            var checkContinue = -1;
            var toRemoveArr = [];
            var newTitleArr = [];
            var childTitleArr = null;
            var endFrameData = null;
            $.each(childArr, function (i, tempChild) {
                if (checkContinue == -1) {
                    checkContinue = tempChild.eTime;
                    endFrameData = tempChild.frameData;
                } else if (checkContinue + 1 >= tempChild.sTime) {
                    if (checkContinue < tempChild.eTime) {
                        checkContinue = tempChild.eTime;
                        endFrameData = tempChild.frameData;
                    } else if (endFrameData == null) {
                        endFrameData = tempChild.frameData;
                    } else {
                        if (tempChild.frameData != null && tempChild.frameData.end != endFrameData.end) {
                            console.log("结尾关键帧不同，清空")
                            endFrameData = null;
                        }
                    }
                } else {
                    VOD.Plugin.tips("error", "条目不连续，不能合并");
                    checkContinue = -2;
                    return false
                }
                if (tempChild.id > 0) {
                    toRemoveArr.push(tempChild.id);
                } else if (tempChild.isMergeMode) {
                    toRemoveArr = toRemoveArr.concat(tempChild.toRemoveArr);
                }
                childTitleArr = JSON.parse(tempChild.title);

                if (childTitleArr.length > 0) {
                    if (tempChild.showTitle != "") {
                        if (childTitleArr.indexOf(tempChild.showTitle) == -1) {
                            childTitleArr = [ tempChild.showTitle ].concat(childTitleArr);
                        }
                    }
                    newTitleArr = newTitleArr.concat(childTitleArr);
                } else {
                    if (tempChild.showTitle != "") {
                        newTitleArr.push(tempChild.showTitle);
                    }
                }
            });
            if (checkContinue > 0) {
                var firstData = childArr[0];
                var newObj = {title: JSON.stringify(newTitleArr), sTime: firstData.sTime, eTime: checkContinue,
                    pic: firstData.pic, regId: firstData.regId, id: 0,
                    isMergeMode: true, children: childArr, toRemoveArr: toRemoveArr,
                    frameData: endFrameData
                };
                $("#news_list").clearGridData();
                VOD.Util.mergeNewsGridData([newObj], childArr)
                VOD.Util.setHighLight(newObj);
                VOD.Util.fromLIstJump(newObj.sTime);
                VOD.Util.doNewsGridScroll(newObj.regId);
                $("#news_list").jqGrid('setSelection', newObj.regId);
            }
        },
        doSourceMerge: function (lastSource, newSource) {
            if (VOD.Config.PageBeanTemp == null) {
                VOD.Config.PageBeanTemp = VOD.Util.createPageBean();
            }
            var pageBean = VOD.Config.PageBeanTemp;
            pageBean.setNewData(newSource);
            var tempElement = null;
            var retSource = [];
            var retFlag = false;
            $.each(lastSource, function (i, element) {
                retFlag = VOD.Util.updateRef(element, pageBean);
                if (retFlag) {
                    retSource.push(element);
                    if (element.isMergeMode) {
                        element.regId = element.children[0].regId;
                        $.each(element.toRemoveArr, function (index, childId) {
                            tempElement = pageBean.findData("id", childId);
                            pageBean.delOne(tempElement);
                        })
                    } else if (element.id > 0) {
                        tempElement = pageBean.findData("id", element.id);
                        pageBean.delOne(tempElement);
                    }
                }
            })
            var rest = pageBean.getSource();
            retSource = retSource.concat(rest);
            retSource.sort(VOD.Config.SORT_RULE.asc_news_regId);
            return retSource;
        },
        updateRef: function (element, pageBean) {
            var retFlag = false;
            if (element.isMergeMode == true) {
                $.each(element.children, function (i, child) {
                    retFlag = VOD.Util.updateRef(child, pageBean);
                    if (!retFlag) {
                        return false;
                    }
                })
            } else if (element.id > 0) {
                var temp = pageBean.findData("id", element.id);
                if (temp != null) {
                    element.regId = temp.regId;
                    retFlag = true;
                }
            } else {
                VOD.Dao.settings.reg_last_id++;
                element.regId = VOD.Dao.settings.reg_last_id;
                retFlag = true;
            }
            return retFlag;
        },
        doChangeTitle: function (element) {
            var $target = $(element);
            var targetId = null;
            if ($target.attr("name") == "tab3_title") {
                // targetId = VOD.NewsHighlight.getLastOption().id;
                targetId = parseInt($("span[name=tabName]").html().replace(/序号|发布/g, ""));
            } else {
                targetId = parseInt($target.attr("data-id"))
            }
            var rowData = VOD.Config.PageBeanNews.findData("regId", targetId);
            rowData.showTitle = $target.val();
            $("#news_list").setRowData(rowData.regId, { title: rowData.title, regId: rowData.regId });
        },
        undoMerge: function (mergeId) {
            var rowData = VOD.Config.PageBeanNews.findData("regId", parseInt(mergeId));
            $.each(rowData.children, function (i, element) {
                element.checked = false;
            })
            VOD.Util.mergeNewsGridData(rowData.children, [rowData])
            VOD.Util.clearHighLight();
            VOD.Util.doNewsGridScroll(mergeId);
            if ($("li[aria-controls=tab3]").is(":visible")) {
                var elementId = $("span[name=tabName]").html().replace(/序号|发布/g, "");
            }
            if (mergeId == parseInt(elementId)) {
                $("li[aria-controls=tab3]").hide();
            }
        },
        mergeNewsGridData: function (addArr, delArr) {
            $.each(delArr, function (i, element) {
                VOD.Config.PageBeanNews.delOne(element)
            })
            $.each(addArr, function (i, element) {
                VOD.Config.PageBeanNews.addNewOne(element)
            })
            VOD.Config.PageBeanNews.sortData(VOD.Config.SORT_RULE.asc_news_regId);
            $("#news_list")[0].addJSONData(VOD.Config.PageBeanNews.getCur());
        },
        clearHighLight: function () {
            VOD.NewsHighlight.setHighLight(null);
        },
        doNewsGridScroll: function (rowid) {
            var bdiv = $("#tab2").find(".ui-jqgrid-bdiv");
            if (bdiv[0].scrollHeight <= bdiv[0].clientHeight) {
                return;
            }
            rowid = rowid + ""
            var allData = $("#news_list").jqGrid("getRowData");
            var interrupt = 0;
            for (var i = 0; i < allData.length; i++) {
                if (allData[i].hidden_news_id == rowid) {
                    interrupt = i;
                    break;
                }
            }
            bdiv.scrollTop(interrupt / allData.length * bdiv[0].scrollHeight);
        },
        doNewsGridResize: function () {
            if ($("#news_list").length > 0) {
                var showHeight = $(window).height() - 890 + 355;
                if (showHeight < 60) {
                    showHeight = 60;
                }
                $("#news_list").setGridHeight(showHeight)
            }
        },
        bindFrameData: function (frameData) {
            var bindId = VOD.NewsHighlight.getLastOption().id;
            var bindData = VOD.Config.PageBeanNews.findData("regId", bindId);
            bindData.frameData = $.extend(true, {}, frameData);
        },

        readPublishFrameData: function (rowId) {
            if (rowId == null) {
                rowId = $("span[name=tabName]").html().replace(/序号|发布/g, "");
            }
            var bindData = VOD.Config.PageBeanNews.findData("regId", rowId);
            if (bindData != null && bindData.frameData != null) {
                VOD.AccurateFrame.readFrameData(bindData.frameData);
            } else {
                VOD.AccurateFrame.doReset();
            }
        },
        fillDefaultTitle:function(){
            var settings = VODNew.Dao.settings;
            var c_sTime = $('input[name=eTime]').val();
            var s_sTime = $('input[name=sTime]').val();
            if (s_sTime == '' && isNaN(s_sTime)){
                return
            }
            if (c_sTime != '' && !isNaN(c_sTime)) {
                if($("input[name=videoName]").val().length > 0){
                    return ;
                }
                if ($('input[name=videotype]:checked').val() == -1) {
                    var show = settings.taskid + '-' + VODNew.Dao.getParamsData().channel_name + '-' + settings.today + '-' + s_sTime + '-' + c_sTime;
                    $('input[name=videoName]').val(show);
                    var ocrFirstTitle = VODNew.Util.binSearchOcrTitle(s_sTime, c_sTime).shift();
                    if (ocrFirstTitle) {
                        $("input[name=videoName]").val(ocrFirstTitle);
                        $("input[name=videoName]").attr("eut", encodeURIComponent(ocrFirstTitle));
                    }
                }
            }
        }
    })
})
;
define(
    '../vod/VOD.Plugin',['require','exports','module'],function (require, exports, module) {
        VOD.Plugin = $.extend(true, {}, EpgWeb.Plugin, {
            tips: (function () {
                var str = '<div class="alert alert-dismissible" role="alert1" style="display: inline;text-align: center;width: 420px">'
                    + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'
                    + '<span id="tips">{{cnt}}</span><strong style="margin-right:30px;">【3秒后自动关闭】</strong>'
                    + '</div>';
                var _timeId = null;

                return function (func, content) {
                    //移除旧对象
                    $("div[role=alert1]").remove();
                    if (_timeId) {
                        clearTimeout(_timeId);
                    }
                    var html = str;
                    html = html.replace(/{{cnt}}/g, content);
                    $(html).appendTo($(document.body));
                    //重新获取
                    var targetElement = $("div[role=alert1]");
                    targetElement.css("left", $(document.body).width() / 2 - $("div[role=alert1]").width() / 2);

                    if (func !== undefined) {
                        if (func == "success") {
                            targetElement.removeClass("alert-danger");
                            targetElement.addClass("alert-success");
                        }
                        else if (func == "error") {
                            targetElement.removeClass("alert-success");
                            targetElement.addClass("alert-danger");
                        }

                        _timeId = setTimeout(function(){
                            $('div[role=alert1]').find("button").trigger("click");
                        }, 3000);
                    }
                    else {
                        console.log("func is not exists!");
                    }
                };
            })(),
            Validate: (function () {
                var reg1 = /^\d+$/;
                var reg3 = /^[1-9]\d*$/;
                var reg2 = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
                var reg4 = /^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/;
                var checkObj = {
                    self_design: function (checkData, checkValue) {
                        return checkData.checkCall(checkData, checkValue)
                    },
                    date: function (checkData, checkValue) {
                        return checkDateFormat(checkValue);
                    },
                    not_empty: function (checkData, checkValue) {
                        return checkValue != null && $.trim(checkValue).length > 0;
                    },
                    eq: function (checkData, checkValue) {
                        return checkValue === checkData.other;
                    },
                    ne: function (checkData, checkValue) {
                        return checkValue !== checkData.other;
                    },
                    ge: function (checkData, checkValue) {
                        return  checkValue >= checkData.other;
                    },
                    gt: function (checkData, checkValue) {
                        return  checkValue > checkData.other;
                    },
                    lt: function (checkData, checkValue) {
                        return checkValue < checkData.other;
                    },
                    le: function (checkData, checkValue) {
                        return checkValue <= checkData.other;
                    },
                    positive: function (checkData, checkValue) {
                        return  checkPositive(checkValue)
                    },

                    number: function (checkData, checkValue) {
                        return checkNum(checkValue);
                    },
                    endsWith: function (checkData, checkValue) {
                        return checkValue != null && typeof(checkValue) == "string" && checkValue.slice(-(checkData.other.length)) == checkData.other;
                    }
                }

                function checkNum(checkString) {
                    return reg1.test(checkString)
                }

                function checkDateFormat(checkString) {
                    return reg2.test(checkString)
                }

                function checkPositive(checkString) {
                    return reg3.test(checkString)
                }

                function defaultHandler(msg) {
                    VOD.Plugin.tips("error", msg);
                }

                function batchCheck(checkArr) {
                    if (checkArr == null) {
                        checkArr = [];
                    }
                    if (checkArr.length == 0) {
                        return true;
                    }
                    var flag = false;
                    $.each(checkArr, function (index, checkData) {
                        flag = baseCheck(checkData);
                        if (!flag) {
                            return false;
                        }
                    })
                    return flag;
                }

                function baseCheck(checkData) {
                    var flag = false;
                    //$.isArray(checkData.value )
                    if (!(checkData.value instanceof Array)) {
                        checkData.value = [checkData.value];
                    }
                    //$.isArray(checkData.error )
                    if (!(checkData.error instanceof Array)) {
                        checkData.error = [checkData.error];
                    }
                    if (checkData.handler == null) {
                        checkData.handler = defaultHandler;
                    }
                    $.each(checkData.value, function (index, checkValue) {
                        if (checkObj.hasOwnProperty(checkData.type)) {
                            flag = checkObj[checkData.type](checkData, checkValue);
                        }
                        if (!flag) {
                            var hint = checkData.error.length == checkData.value.length ? checkData.error[index] : checkData.error[0];
                            checkData.handler(hint);
                            return false;
                        }
                    })
                    return flag
                }

                return {
                    baseCheck: baseCheck,
                    batchCheck: batchCheck,
                    checkDateFormat: checkDateFormat,
                    checkNum: checkNum
                }
            })()
        })

    }
);
define(
    '../vod/VOD.Evt',['require','exports','module'],function (require, exports, module) {
        VOD.Evt = {
            InitBindEvt: function () {
                // 显示小窗口视频预览
                var playOneInfo = VOD.Dao.playOneInfo;
                $("#makedImg").on("mouseenter mouseleave", "img", function (event) {
                    var self = $(this);
                    if (event.type == 'mouseenter') {
                        playOneInfo.mouseenter = true;
                        playOneInfo.left = self.offset().left - $("#play-one").width();
                        playOneInfo.top = self.offset().top;
                        playOneInfo.time = self.attr("id").split("-")[1];
                    } else if (event.type == 'mouseleave') {
                        playOneInfo.mouseenter = false;
                        $("#play-one").css({
                            top: '-1000px',
                            left: '-1000px'
                        });
                    }
                });
                $(".cVideo").click(function () {
                    if ($(this).attr('data') == 'cover-program') {
                        $("#cover-program-cfm").show();
                    } else {
                        $("#cover-program-cfm").hide();
                    }
                });
                $('#ase-close').on('click', function () {
                    VOD.AccurateFrame.accurateStartEndRemove()
                });
            },
            // 显示和隐藏打点打条列表
            ShowAndHideSegmentationList: function () {
                var list = $(".segmentation").find(".list");
                if (list.attr("data-show") == "false") {
                    list.show();
                    list.attr("data-show", "true");
                    $(".title").find(".glyphicon").addClass("glyphicon-chevron-down");
                    $('#list-slide-shrink').text('收起');
                } else {
                    list.hide();
                    list.attr("data-show", "false");
                    $(".title").find(".glyphicon").removeClass("glyphicon-chevron-down");
                    $('#list-slide-shrink').text('展开');
                }
            },

            // 打开关闭背景颜色
            OpenOrCloseBk: function (self) {
                if (!self.hasClass("switch-position")) {
                    self.addClass("switch-position");
                    VOD.Dao.storageData('BCS', 'on');
                    $('.fragment-img').removeClass('c000');
                    $('.in-out-mark-s').show();
                } else {
                    self.removeClass("switch-position");
                    VOD.Dao.storageData('BCS', 'off');
                    $('.fragment-img').addClass('c000');
                    $('.in-out-mark-s').hide();
                }
            },

            SelectAll: function (self) {
                if (self.is(':checked'))

                    $.each($(".tab-content input[type='checkbox']"), function () {

                        if (!$(this).attr('readOnly'))
                            $(this).prop('checked', true);

                    });
                else
                    $(".tab-content input[type='checkbox']").prop('checked', false);
            },

            CheckedSegId: function (self) {
                var $tr = self.parents("tr"),
                    options = {};

                options.st = $tr.find('[name$="sTime"]').val();
                options.et = $tr.find('[name$="eTime"]').val();
                options.color = "c09f";
                if (!options.st)
                    return;

                if (self.is(":checked")) {
                    fromLIstJump(options.st);
                    VOD.Util.addBackgroundColor(options);
                } else {
                    options.removeColor = true;
                    VOD.Util.addBackgroundColor(options);
                }

            },

            // 合并已选拆条
            SubAllMerge: function () {
                var merg = {
                        range: '',
                        imageId: '',
                        sTime: '',
                        eTime: '',
                        albumName: '',
                        albumId: '',
                        videoName: ''
                    },
                    $check = $("#tab2").find('[action-name="checked-seg-id"]:checked');
                len = $check.length;

                if (len > 0) {
                    var sTime,
                        eTime
                    mergData = [];

                    $.each($check, function (i, item) {

                        var $parent = $(this).parents('.inner-table'),
                            st = $parent.find('[name$="sTime"]').val(),
                            et = $parent.find('[name$="eTime"]').val(),
                            seg = '';

                        if (!merg.sTime) {
                            merg.sTime = st;
                            merg.albumName = $parent.find('[name$="albumName"]').val();
                            merg.albumId = $parent.find('[name$="albumId"]').val();
                            merg.videoName = $parent.find('[name$="videoName"]').val();
                            merg.categoryId = $parent.find('[name$="categoryId"]').val();
                        }

                        eTime = et;

                        $(this).trigger('click');

                        if (i < len - 1)
                            seg = ',';

                        merg.range = merg.range + $(this).val() + '(' + st + '-' + et + ')' + seg;
                        mergData.push(st + '_' + et);

                        if (!merg.imageId)
                            merg.imageId = st;
                    });

                    merg.eTime = eTime;
                    merg.mergData = mergData;

                    VOD.Util.appendMergeSeg(merg);

                    $('[action-name="merge-segmentation-tab"]').trigger('click');
                    //console.log(merg);
                    $('[data-id="' + merg.sTime + '"]').val(merg.categoryId);

                    $('.merg-seg-tips').hide();
                } else
                //alert('请选择要合并项');
                    VOD.Plugin.tips("error", '请选择要合并项');
            },

            // 提交已选择所有拆条
            SubAllSeg: function () {

                if (VOD.Dao.settings.taskid < 1) {
                    //alert('任务ID为空,不能提交!');
                    VOD.Plugin.tips("error", '任务ID为空,不能提交!');
                    return false;
                }

                var $check = $("#tab2").find('[action-name="checked-seg-id"]:checked'),
                    len = $check.length;

                if (len > 0) {
                    $.each($check, function (i, item) {
                        var $parent = $(this).parents('.inner-table');
                        //console.log($(this).val());
                        //$(this).trigger('click');
                        VOD.Evt.SubAutoSeg($parent.find('[action-name="sub-seg"]'));
                    });
                } else
                //alert('请选择要提交的拆条');
                    VOD.Plugin.tips("error", '请选择要提交的拆条');
            },

            // 提交已选择所有广告
            SubAllAd: function () {
                var $check = $("#tab2").find('[action-name="checked-seg-id"]:checked'),
                    len = $check.length;

                if (len > 0) {
                    $.each($check, function (i, item) {
                        var $parent = $(this).parents('.inner-table');

                        $(this).trigger('click');
                        VOD.Evt.SubAutoAd($parent.find('[action-name="sub-ad"]'));
                    });
                } else
                //alert('请选择要提交的广告');
                    VOD.Plugin.tips("error", '请选择要提交的广告');
            },
// 自动拆条input操作时添加背景色

            // 定时提醒
            RegularTimeRemind: function () {
                var regularTime = $("#alert-time").val();

                if (regularTime && regularTime != "undefined") {
                    (function () {
                        var compareTimeRt = -1, //时间比较结果
                        //blinkTimes = 0,     //闪烁次数
                        //settedTime = '',
                            isTimeArriveInt = null;
                        $("#alert-pop").attr("disabled", "disabled");

                        //alert("添加成功");
                        VOD.Plugin.tips("success", '添加成功');

                        var isTimeArrive = function () {
                            var time = $("#alert-time").val();
                            var now = new Date();
                            var nowStr = VOD.Util.formatDateTimeFormat(now);
                            compareTimeRt = VOD.Util.compareTime(time, nowStr);
                        };

                        var titleWink = function () {
                            // blinkTimes++;
                            //if(blinkTimes==3){blinkTimes=1}

                            if (compareTimeRt >= 0) {
                                window.focus();
                                alert('【' + VOD.Dao.getParamsData().channel_name + '】【' + regularTime + '】预定时间已到!');
                                $("#alert-pop").removeAttr("disabled");
                                $("#alert-time").val("");
                                clearInterval(isTimeArriveInt);
                                return;
                            }
                            setTimeout(titleWink, 200);
                        };

                        isTimeArriveInt = setInterval(isTimeArrive, 200);
                        //settedTime = time;
                        titleWink();

                    })();
                } else {
                    //alert("时间不能为空");
                    VOD.Plugin.tips("error", '时间不能为空');
                }
            },

            // 提交广告智能入库
            saveAdLibrary: function (targetElement) {
                var settings = VOD.Dao.settings;
                var taskid = settings.taskid;
                if (taskid < 1) {
                    //alert('任务ID为空,不能提交!');
                    VOD.Plugin.tips("error", '任务ID为空,不能提交!');
                    return false;
                }

                var options = {};

                if (settings.delList.length === 0) {
                    VOD.Plugin.tips("error", '广告列表数据不能为空！');
                    return false;
                }
                var params = VOD.Dao.getParamsData();
                options.list = '[' + settings.delList.join(',') + ']';

                options.key = taskid;
                options.channelId = params._channel_id;
                options.offsets = VOD.AccurateFrame.getAdAccurate();  // 广告精确化

                if (!options.channelId.length) {
                    //alert('频道ID为空,不能提交!');
                    VOD.Plugin.tips("error", '频道ID为空,不能提交!');
                    return false;
                }

                options.ablumId = $('input[name=albumName]').suggest("getValue");
                if (!options.ablumId.length) {
                    //alert('专辑ID为空,不能提交!');
                    VOD.Plugin.tips("error", '专辑ID为空,不能提交!');
                    return false;
                }

                VOD.Dao.saveAdLibrary(options, function (data) {

                    if (data.error != 0) {
                        //alert(erroNo + '' + data.error);
                        VOD.Plugin.tips("error", "广告入智能库失败！");
                        targetElement.removeClass("disabled");
                    }
                    else {
                        //alert("广告入智能库提交成功！");
                        VOD.Plugin.tips("success", "广告入智能库提交成功！");
                        targetElement.removeClass("disabled");
                        //adLibList = [];
                    }
                });
            },

            // 提交专辑智能入库
            saveAlbumLibrary: function (targetElement) {
                var options = {};

                var taskid = VOD.Dao.settings.taskid;
                if (taskid < 1) {
                    //alert('任务ID为空,不能提交!');
                    VOD.Plugin.tips("error", '任务ID为空,不能提交!');
                    return false;
                }

                var sTime = $('input[name=sTime]').val(),
                    eTime = $('input[name=eTime]').val();
                if (isNaN(sTime) || !sTime) {
                    //alert('起始帧有误,必须为数字类型');
                    VOD.Plugin.tips("error", '起始帧有误,必须为数字类型');
                    return false;
                }
                if (isNaN(eTime) || !eTime) {
                    //alert('结束帧有误,必须为数字类型');
                    VOD.Plugin.tips("error", '结束帧有误,必须为数字类型');
                    return false;
                }

                var acrossTtime = eTime - sTime;
                var genList = function (head, end, n) {
                    var list = {};
                    list.head = [head];
                    list.end = [end];
                    n = n - 1;
                    if (n >= 6) {
                        n = 6;
                    }
                    for (var i = 1; i <= n; i++) {
                        list.head.push(head + i);
                    }
                    for (var j = 1; j <= n; j++) {
                        list.end.unshift(end - j);
                    }
                    list.head = '[' + list.head.join(',') + ']';
                    list.end = '[' + list.end.join(',') + ']';
                    return list;
                }

                options.list = genList(parseInt(sTime), parseInt(eTime), acrossTtime);

                options.key = taskid;

                options.ablumId = $('input[name=albumName]').suggest("getValue");
                if (!options.ablumId.length) {
                    //alert('专辑ID为空,不能提交!');
                    VOD.Plugin.tips("error", '专辑ID为空,不能提交!');
                    return false;
                }
                var frameData = VOD.AccurateFrame.getAccurateFrame()
                if (!frameData.headSetted) {
                    frameData.head = 0;
                }

                if (!frameData.endSetted) {
                    frameData.end = 0;
                }

                options.offset = {'head': frameData.head, 'end': frameData.end}
                options.channelId = VOD.Dao.getParamsData()._channel_id;
                if (!options.channelId.length) {
                    VOD.Plugin.tips("error", '频道ID为空,不能提交!');
                    return false;
                }

                targetElement.addClass("disabled");

                VOD.Dao.saveAlbumLibrary(options, function (data) {
                    if (data.error != 0) {
                        VOD.Plugin.tips("error", data.error);
                        targetElement.removeClass("disabled");
                    }
                    else {
                        VOD.Plugin.tips("success", "专辑入智能库提交成功！");
                        targetElement.removeClass("disabled");
                    }
                });
            },
            setVideoName: function () {
                var val = $('input:radio[name="optionsRadios"]:checked').parent().text();
                VOD.Config.Global.statisticOcrTitle = val;
                $("input[name=videoName]").val(val);
                $("input[name=videoName]").attr("eut", $('input:radio[name="optionsRadios"]:checked').val());
            },
            setOcrTitleList: function () {
                var s_sTime = $('input[name=sTime]').val();
                var s_eTime = $('input[name=eTime]').val();
                if (s_sTime == "undefined" || s_sTime == "" || s_eTime == "undefined" || s_eTime == "") {
                    $("#ocr-detail").html("<div style=\"color:grey;height:150px;\">起始结束帧不能为空！</div>");
                    return;
                }
                var tmp = VOD.Util.binSearchOcrTitle(s_sTime, s_eTime);
                if (tmp == '') {
                    $("#ocr-detail").html("<div style=\"color:grey;height:150px;\">没有识别到的标题！</div>");
                    return;
                }

                var checkboxHtml = '';
                var k = 1;

                var outTmp = $("input[name=videoName]").attr("eut");
                var eut = '';
                var ck = "";
                for (var i in tmp) {

                    if (outTmp != '') {
                        eut = encodeURIComponent(tmp[i]);
                        if (outTmp == eut) {
                            ck = 'checked';
                        } else {
                            ck = '';
                        }
                    } else {
                        if (k == 1)
                            ck = 'checked';
                        else
                            ck = '';
                        k++;
                    }

                    checkboxHtml += '<div class="radio">'
                        + '<label  ondblclick="VOD.Evt.setVideoDesc()">'
                        + '<input type="radio" name="optionsRadios" value="' + eut + '" ' + ck + '>'
                        + tmp[i]
                        + '</label>'
                        + '</div>';
                }

                $("#ocr-detail").html(checkboxHtml);
            },
            setAcrTitleList: function () {
                var s_sTime = $('input[name=sTime]').val();
                var s_eTime = $('input[name=eTime]').val();

                if (s_sTime == "undefined" || s_sTime == "" || s_eTime == "undefined" || s_eTime == "") {
                    $("#acr-detail").html("<div style=\"color:grey;height:150px;\">起始结束帧不能为空！</div>");
                    return;
                }

                var tmp = VOD.Util.binSearchAcrTitle(s_sTime, s_eTime);
                if (tmp == '') {
                    $("#acr-detail").html("<div style=\"color:grey;height:150px;\">没有识别到描述！</div>");
                    return;
                }
                var checkboxHtml = '';
                var k = 1;
                var eut = '';
                var ck = "";
                var outTmp = $("textarea[name=desc]").attr("eut");

                for (var i in tmp) {

                    eut = encodeURIComponent(tmp[i]);
                    if (outTmp != '') {
                        var f = new RegExp(eut, 'gi');
                        if (f.test(outTmp)) {
                            ck = 'checked';
                        } else {
                            ck = '';
                        }
                    } else {
                        if (k == 1)
                            ck = 'checked';
                        else
                            ck = '';
                        k++;
                    }

                    checkboxHtml += '<div class="checkbox">'
                        + '<label  ondblclick="VOD.Evt.setVideoDesc()">'
                        + '<input type="checkbox" name="optionsCheckboxs" value="' + eut + '" ' + ck + '>'
                        + tmp[i]
                        + '</label>'
                        + '</div>';
                }

                $("#acr-detail").html(checkboxHtml);
            },
            setVideoDesc: function () {
                var val = '';
                var var2 = '';
                var val1 = $('input:checkbox[name="optionsCheckboxs"]:checked');
                $.each(val1, function (i, n) {
                    val += $(n).parent().text();
                    var2 += $(n).val();
                });
                $("textarea[name=desc]").val(val);
                $("textarea[name=desc]").attr("eut", var2);
            }
        };

    }
);
define(
    '../vod/VOD.Dao',['require','exports','module'],function (require, exports, module) {
        VOD.Dao = $.extend({}, EpgWeb.Dao, {
            cache: {},
            settings: {
                index: 1,
                stime: 0,
                etime: 0,
                pic: 0,
                taskid: 0,
                lastImg: 0,
                delList: [],
                subData: [],
         //       needDatas: [],
                isStart: false,
                isSetFpTime: false,
                lb: 1,
                firstFpTime: 0,
                last_i: 0,   // 上次识的库索引
                adLibList: [],
                isOver: 1,  //防止并发
                fpTime: 'fp_time',

                // page use
                period: '',
                linePicNum: 9,
                today: '',
             //   videonameArr:[],
                g_ocrList:[],
                g_acrList:[],
                reg_last_id: 0
            },
            playOneInfo: {mouseenter: false},
            getParamsData: function () {
                return this.getDataByName("params");
            },
            // 入广告智能库
            saveAdLibrary: function (options, callback) {
                options.from_client = true;  //绕过鉴权
                var url = this.getDotData().smartLibrary;
                $.ajax({
                    cache: false,
                    async: false,
                    type: "post",
                    url: url + 'doad',
                    data: options,
                    success: function (res) {
                        callback.call(this, res);
                    },
                    dataType: "json",
                    error: function () {
                        //alert('网络错误,请稍后再入广告智能库！');
                        VOD.Plugin.tips("error", '网络错误,请稍后再入广告智能库！');
                    }
                });
            },
            // 专辑入智能库
            saveAlbumLibrary: function (options, callback) {
                options.from_client = true;

                var head = options.list.head,
                    end = options.list.end,
                    aHead = options.offset.head,
                    aEnd = options.offset.end;

                options.list = head;
                options.offset = aHead;
                var url = this.getDotData().smartLibrary;
                $.ajax({
                    cache: false,
                    async: false,
                    type: "post",
                    url: url + 'dohead',
                    data: options,
                    success: function (res) {
                        options.list = end;
                        options.offset = aEnd;

                        $.ajax({
                            cache: false,
                            async: false,
                            type: "post",
                            url: url + 'doend',
                            data: options,
                            success: function (res) {
                                callback.call(this, res);
                            },
                            dataType: "json",
                            error: function () {
                                //alert('网络错误,请稍后再入广告智能库！');
                                VOD.Plugin.tips("error", '网络错误,请稍后再入广告智能库！');
                            }
                        });
                    },
                    dataType: "json",
                    error: function () {
                        //alert('网络错误,请稍后再专辑入智能库！');
                        VOD.Plugin.tips("error", '网络错误,请稍后再专辑入智能库！');
                    }
                });
            },

            getDotData: function () {
                return this.getDataByName("dot");
            },
            getDataByName: function (targetName) {
                if (!this.cache.hasOwnProperty(targetName)) {
                    if (this.hasOwnProperty("method_" + targetName)) {
                        var target = this["method_" + targetName]();
                        this.cache[targetName] = target;
                        return target;
                    } else {
                        return null;
                    }
                } else {
                    return this.cache[targetName];
                }
            },
            method_params: function () {
                var queryStringObj = VOD.Util.getUrlParams();
                var obj = {};
                obj["channel_name"] = queryStringObj['channel_code'];
                obj["ip"] = queryStringObj['ip'];
                obj["freeType"] = queryStringObj['free_type'];
                obj["_channel_id"] = queryStringObj['channel_id'];
                obj["_channel_name_str"] = queryStringObj['cn'];
                obj["locationCategory"] = queryStringObj['locationCategory'];
                obj["location"] = queryStringObj['location'];
                obj["startTime"]=queryStringObj['startTime'];
                obj["endTime"]=queryStringObj['endTime'];
                return obj;
            },
            method_dot: function () {
                var params = this.getParamsData();
                var obj = {};
                obj.dotUrl = 'http://' + params.ip + ':8080/dot/dodot';
                obj.adUrl = 'http://' + params.ip + ':8080/dot/doadstore'; // 广告入库学习
                obj.listUrl = 'http://' + params.ip + ':8080/dot/json';
                obj.initUrl = 'http://' + params.ip + ':8080/dot/init';
               // obj.cateUrl = 'http://' + params.ip + ':8080/dot/cate';
                obj.sty2Url = 'http://' + params.ip + ':8080/dot/sty2';//智能分析
                obj.ocrUrl = 'http://' + params.ip + ':8080/dot/ocr';
                obj.acrUrl = 'http://' + params.ip + ':8080/dot/acr';
                obj.channelInfoUrl = 'http://' + params.ip + ':8080/channel/channelinfo';
                obj.analysis = 'http://' + params.ip + ':9090/dot/analysis';
                obj.sty = 'http://' + params.ip + ':8080/dot/sty'; // 自动拆条
                obj.codeVersionUrl = 'http://' + params.ip + ':8080/version'; // 编码器版本号
                obj.smartLibrary = 'http://' + params.ip + ':8080/dot/';
                return obj;
            },
            // 获取合作方信息
            getCooperativePartner : function (options, callback) {
                if (options.channeltype == 'undefined' || options.channelalias == 'undefined' || options.channeltype == '' || options.channelalias == '')
                    return '';
                $.get(VOD.urlConfig.partnerUrl, options, function (res) {
                    if (res.code == 200) {
                        callback.call(this, res.response.data);
                    } else {
                        console.log("【合作方失败信息】" + res.msg);
                    }
                }, 'json');
            },
            getCodeVersion : function (options) {
              var codeVersionUrl =  this.getDotData().codeVersionUrl;
                $.ajax({
                    cache : false,
                    async : false,
                    type : "get",
                    url : codeVersionUrl,
                    data : {
                        'data' : JSON.stringify(options)
                    },
                    success : function (data) {
                        VOD.Dao.storageData('coderVersion', data);
                    },
                    error : function () {
                        console.log('请求编码器版本号失败,请稍后再试！');
                    }
                });
            },
            getChannelType:function(handler){
                var options = {
                    url:  VOD.Constant.thirdUrl_channel,
                    type: "get",
                    data:{size:100},
                    success: function (data) {
                        var formatData = [];
                        $.each(data.data,function(i,element){
                            formatData.push({id:element.id,label:element.name,value:element.name})
                        })
                        handler(formatData);
                        console.log("renderPanel happen");
                    },
                    error:function(data){
                        console.log("error happen");
                    }
                }
                this.sendProxy(options);
            },
            delNews:function(data,callback){
                var url = this.getDotData().sty;
                var options = {
                    type: "post",
                    url: url,
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                $.ajax(options);
            },
            getNewsList:function(data,callback){
                var url = this.getDotData().sty;
                //var url = "http://10.23.70.35:8080/dot/sty"
                this.doGet( url,data,callback );

            },
            // original structure
            storageData: function (name, value) {
                var DSN = $('#storage-data');
                if (!value && !name)
                    return '';
                else if (value == undefined)
                    return DSN.data(name);
                else
                    DSN.data(name, value);
            }
        })
    }
);
define(
    '../vod/VOD.Edit',['require','exports','module'],function (require, exports, module) {
        VOD.Edit = function (options) {
            this.dao = VOD.Dao;
            this.task = VOD.Task;
            this.config = VOD.Config;
            this.options = options || {};
        };
        Com.inherits(VOD.Edit,     Ancestor.Grid, function (options) {
        }).extend({
            init: function () {
                VOD.Player.initPlayer();
                var self = this;
                self.initPointTime();
                self.initDlg();
                self.bindEvent();
                self.initBodyEvent();
                self.initSuggest();
                self.initInterValTask();
                self.initGrid();
                VOD.Util.limitWordCount($("input[name=videoName]"), 43,null,null,function(length){
                    $("span.leftWordsCount").text(length);
                });
                VOD.Util.limitWordCount($("textarea[name=fantasyTitle]"), 80,true,['\r','\n'],function(length){
                    $("span.leftWordsCount1").text(length);
                });
            },

            initBodyEvent: function () {
                var self = this;
                var browser = VOD.Util.getUserAgent();
                VOD.Util.detectBrowserSupport(browser);
                VOD.Util.LayoutInit();


                VOD.Util.autoSegmentationTabOptions({});

                self.dao.storageData('ASS', 'off'); // 自动拆条开关
                self.dao.storageData('BCS', 'off'); // 背景颜色开关

                //  self.dao.getAlbum();
//                $('body [href^=#]').click(function (e) {
//                    e.preventDefault();
//                });

//                VOD.Evt.segInputAddBackgroundColor();
//                VOD.Evt.segInputScroll();
//                VOD.Evt.segInputBlur();
                VOD.Evt.InitBindEvt();

                VOD.Util.browserZoomTips();
                $("body").show();
                $("body").on('click', '[action-name]', function () {
                    var self = $(this),
                        name = self.attr('action-name');
                    switch (name) {
                        case 'segmentation':
                            VOD.Evt.ShowAndHideSegmentationList();
                            break;
                        case 'switch': // 拆条背景颜色打开与关闭
                            VOD.Evt.OpenOrCloseBk(self);
                            break;
//                        case 'auto-segmentation': // 自动拆条
//                            VOD.Evt.AutoSegmentate(self);
//                            break;
//                        case 'auto-segmentation-tab': // 自动拆条tab标签上的参数选项禁用与否
//                            VOD.Evt.OpenSegmentationTabOptions({
//                                name: 'auto-segmentation-tab'
//                            });
//                            break;
//                        case 'merge-segmentation-tab':
//                        case 'segmentation-params-tab':
//                            VOD.Evt.OpenSegmentationTabOptions({
//                                name: ''
//                            });
//                            break;
                        case 'select-all':
                            VOD.Evt.SelectAll(self);
                            break;
//                        case 'sub-seg':
//                            VOD.Evt.SubAutoSeg(self);
//                            break;
//                        case 'sub-ad':
//                            VOD.Evt.SubAutoAd(self);
//                            break;
                        case 'checked-seg-id':
                            VOD.Evt.CheckedSegId(self);
                            break;
                        case 'sub-all-seg':
                            VOD.Evt.SubAllSeg(self);
                            break;
                        case 'sub-all-ad':
                            VOD.Evt.SubAllAd(self);
                            break;
                        case 'sub-all-merge':
                            VOD.Evt.SubAllMerge(self);
                            break;
//                        case 'sub-all-del':
//                            VOD.Evt.SubAllDel(self);
//                            break;
                        case 'save-ad-smart-library':
                            VOD.Evt.saveAdLibrary(self);
                            break;
                        case 'save-album-smart-library':
                            VOD.Evt.saveAlbumLibrary(self);
                            break;

                        default:
                            break;
                    }

                });
            },

            initInterValTask: function () {
                var self = this;
                setInterval(self.task.getData, 5000);   // 获取图片数据
                //setInterval(getCate,20000);
                setInterval(self.task.getSty2, 19000);   // 智能识别数据
                setInterval(self.task.getOcr, 23000);
                setInterval(self.task.getAcr, 11000);
            },
            initPointTime: function () {
                //默认时间
                var today_d = new Date();

                if(today_d.getMinutes() > 2  ){
                    today_d.setTime(today_d.getTime()- 120000 );
                }
                var s_d = VOD.Util.formatDateTimeFormat(today_d );
                today_d.setTime(today_d.getTime() +  4*3600*1000 );
                var e_d = VOD.Util.formatDateTimeFormat(today_d );
                $('#inputStartTime').val(s_d);
                $('#inputEndTime').val(e_d);
                if( s_d >= e_d){
                    return
                }
                VOD.Util.bindDate("inputStartTime", "inputEndTime", { maxDate: e_d, maxDateTime: new Date(e_d.replace(/-/g, "/")), minDate: s_d, minDateTime: new Date(s_d.replace(/-/g, "/"))});
                $("input[name=inputStartTime]").datetimepicker("setDate", new Date(s_d.replace(/-/g, "/")));
                $("input[name=inputEndTime]").datetimepicker("setDate", new Date(e_d.replace(/-/g, "/")));
            },
            initDlg: function () {
                var self = this;

                $("#ocr-dlg").dialog({
                    title: "修改标题",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 600,
                    modal: true})
                $("#acr-dlg").dialog({
                    title: "修改描述",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 600,
                    modal: true
                })


                $("#alert-dlg").dialog({
                    title: "定时提醒",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 600,
                    modal: true
                })
                self.initAlterTitleDlg();
                self.initHelp();
                self.initHelp2();
                $(".ui-dialog-titlebar-close").html('<span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">close</span>');
                $('#alert-time').datetimepicker();
                $("#help-pop").bind("click", function () {
                    var helpDlg = null;
                    if(VOD.Util.isTab2Show() || VOD.Util.isTab3Show()){
                        helpDlg = $("#help2-dlg")
                    }else{
                        helpDlg =  $("#help-dlg")
                    }

                    if (self.dao.storageData('coderVersion') == undefined) {
                        self.dao.getCodeVersion({});
                        if (self.dao.storageData('coderVersion') == undefined) {
                            self.dao.storageData('coderVersion', '0 | 0 | 0');
                        }
                        helpDlg.dialog("open");
                        helpDlg.find("label[name=coderVersion]").html("版本 V3.2.2 | " + self.dao.storageData('coderVersion'));
                    } else {
                        helpDlg.dialog("open");
                    }
                })
                $("#ocr").bind("click",function(e){
                    if ($("#ocr").hasClass("disabled")) {
                      return ;
                    }
                    $("#ocr-dlg").dialog("open");
                    VOD.Evt.setOcrTitleList();
                })
                $("#acr").bind("click",function(e){
                    if ($("#acr").hasClass("disabled")) {
                        return ;
                    }
                    $("#acr-dlg").dialog("open");
                    VOD.Evt.setAcrTitleList();
                })
                $("#alert-pop").bind("click", function () {
                    $("#alert-dlg").dialog("open");
                })
                $("button[name=alert-dlg-cancel]").bind("click", function (e) {
                    $("#alert-dlg").dialog("close");
                });
                $("button[name=alert-dlg-ok]").bind("click", function (e) {
                    VOD.Evt.RegularTimeRemind();
                    $("#alert-dlg").dialog("close");
                });
                $("button[name=ocr-dlg-cancel]").bind("click", function (e) {
                    $("#ocr-dlg").dialog("close");
                });
                $("button[name=ocr-dlg-ok]").bind("click", function (e) {
                    VOD.Evt.setVideoName();
                    $("#ocr-dlg").dialog("close");
                });
                $("button[name=acr-dlg-cancel]").bind("click", function (e) {
                    $("#acr-dlg").dialog("close");
                });
                $("button[name=acr-dlg-ok]").bind("click", function (e) {
                    VOD.Evt.setVideoDesc();
                    $("#acr-dlg").dialog("close");
                });
                $('button[data-dismiss=modal]').on('click', function () {
                    VOD.AccurateFrame. accurateStartEndRemove()
                });
            },
            initHelp:function(){
                $("#help-dlg").dialog({
                    title: "打点系统帮助",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 600,
                    modal: true
                })
                var innerText = "";
                $.each(VOD.Config.HELP_DATA, function (i, data) {
                    innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
                })
                $("#help-dlg").find("tbody").html(innerText);
            },
            initHelp2:function(){

            },
            initAlterTitleDlg:function(){

            },
            bindEvent: function () {
                var self = this;
                var settings = self.dao.settings;
                var global = VOD.Config.Global;
                VOD.Evt.InitBindEvt();

                var sty = '';
                $('#submitStartTime').click(function () {
                    if (self.dao.storageData('ASS') == 'on') {
                        if (!self.dao.storageData('sty-intval')) {
                         //   sty = setInterval(self.dao.getSty, 10000);
                            self.dao.storageData('sty-intval', 1);
                        }
                    } else {
                        clearInterval(sty);
                        self.dao.storageData('sty-intval', 0);
                        self.dao.storageData('sty-index', 0);
                        VOD.g_mi = 0;
                        VOD.g_i = 0;
                    }

                    // 清除已列拆条
                    $('.inner-table').parents('tr').remove();
                    $('.merg-seg-tips,.auto-seg-tips').show();

                    self.updateDaoSetting();
//                    if (error.length) {
//                        //alert(error);
//                        VOD.Plugin.tips("error", error);
//                        return false;
//                    }
                    VOD.Config.PageBeanFrame.setNewData([]);
                    VOD.Config.PageBeanAdvert.setNewData([]);
                    VOD.Util.updateGridFrame();
                    VOD.Util.updateGridAdvert();
                    var start = VOD.Util.validStart();
                    if (!start) {
                        return false;
                    }
                    $('#makedImg').html('正在请求数据，请等待！');
                    var paramsData = self.dao.getParamsData();
                    var dotData = self.dao.getDotData();
                    $.ajax({
                        type: "get",
                        url: dotData.initUrl,
                        data: {
                            'start': start,
                            'period': settings.period,
                            'code': paramsData.channel_name,
                            'from_client': true
                        },
                        success: function (data) {
                            if (data.taskid) {
                                settings.taskid = parseInt("" + data.taskid);
                                settings.lastImg = 0;
                                //开始请求数据
                                settings.isStart = true;
                                $('#makedImg').empty();
                                self.task.getData();
                                if( $("li[aria-controls=tab3]").length > 0){
                                    self.queryNews();
                                }
                            } else {
                                //alert('系统错误:任务id为空');
                                VOD.Plugin.tips("error", '系统错误:任务id为空');
                                return false;
                            }
                        },
                        dataType: "json",
                        error: function () {
                            //alert('网络错误');
                            VOD.Plugin.tips("error", '网络错误');
                        }
                    });
                    //////////////////////////////////////////
                    VOD.Advert.clearCache();
                    //////////////////////////////////////////
                })

                $('#changeBigPic').click(function () {
                    settings.lb = 1;
                    $('.right img').css({
                        'width': '264px',
                        'height': '204px'
                    });
                    VOD.Config.Global.picWH = VOD.Config.BIG_PIC_MODE;

                    $(this).addClass('btn-primary');
                    $('#changeSmallPic').removeClass('btn-primary');
                    $('.breakWord').remove();
                    if (global.isClicked) {
                        var sTop = $('#makedImg').scrollTop() + $('.red').offset().top;
                        $('#makedImg').scrollTop(sTop);
                    }
                    global.smallPic = false;
                    $('.fp_time').removeClass('fp_time').addClass('fp_time2');
                    $('.in-out-mark-s').addClass('in-out-mark-b');
                    settings.fpTime = 'fp_time2';
                    VOD.Util.getLineWidth();
                    VOD.Util.addClearFix();
                    $("#play-one").css({
                        width: "274px",
                        height: "210px"
                    });
                })
                $('#changeSmallPic').click(function () {
                    settings.lb = 1;
                    $('.right img').css({
                        'width': '104px',
                        'height': '64px'
                    });
                    VOD.Config.Global.picWH = VOD.Config.SMALL_PIC_MODE;

                    $(this).addClass('btn-primary');
                    $('#changeBigPic').removeClass('btn-primary');
                    $('.breakWord').remove();
                    if (global.isClicked) {
                        sTop = $('#makedImg').scrollTop() + $('.red').offset().top;
                        $('#makedImg').scrollTop(sTop);
                    }
                    global.smallPic = true;
                    $('.fp_time2').removeClass('fp_time2').addClass('fp_time');
                    $('.in-out-mark-s').removeClass('in-out-mark-b');
                    settings.fpTime = 'fp_time';
                    VOD.Util.getLineWidth();
                    VOD.Util.addClearFix();
                    $("#play-one").css({
                        width: "140px",
                        height: "105px"
                    });
                })

                // 标题、专辑、合作方suggest鼠标移出隐藏
//                $('.cn_hide,.cn_hide2,.cn_hide3').hover(function () {
//                }, function () {
//                    $(this).hide();
//                })
                self.bindReviewInfo();
                self.bindAddInfo();
                self.bindJumpSubmitHandler();
                self.bindMarkImgHandler()

                $('#adv').click(function () {
                    //   20
                    $('input[name=videoName]').suggest("setValue", {id: 20, label: "广告"});
                    $('input[name=categoryName],input[name=albumName],input[name=imageId]').attr('disabled', 'disabled');
                });
                $('#mer').click(function () {
                    $('input[name=videoName]').suggest("setValue", "");
                    $('input[name=categoryName],input[name=albumName],input[name=imageId]').removeAttr('disabled');
                });
                $('.cVideo').click(function () {
                    $('input[name=albumName],input[name=imageId],input[name=categoryName]').removeAttr('disabled');
                })
                $('select[name=jumpType]').change(function () {
                    if ($(this).val() == 1) {
                        $('#jumpContent').val('00:00:00');
                    } else {
                        $('#jumpContent').val('0');
                    }
                })
                $('#autoRunPic').click(function () {
                    if ($(this).prop('checked')) {
                        sTop = $('#makedImg')[0].scrollHeight;
                        $('#makedImg').scrollTop(sTop);
                    }
                })

                $("input[name=videotype]").bind('click', function () {
                    //settings.videonameArr = [];
                    $('input[name=videoName]').suggest("setValue", "");
                    $("input[name=albumName]").suggest("setValue", "");
                    if ($(this).val() == -1) {
                        $("#ocr").show();
                        $("#acr").show();
                        $('#fantasyTitleDiv').css('display', 'block');
                        if ($("input[name=categoryName]").suggest("getValue") == 25) {
                            $("#locationDiv").show();
                        } else {
                            $("#locationDiv").hide();
                        }
                    } else {
                        $("#locationDiv").hide();
                        $('#fantasyTitleDiv').css('display', 'none');
                        $("#ocr").hide();
                        $("#acr").hide();
                    }
                    var categoryName = $("input[name=categoryName]").val();
                    VOD.Util.setCooperativePartner(categoryName);
                });

//                $("input[name=videoName]").focus(function () {
//                    $(this).addClass("videoName")
//                }).blur(function () {
//                    $(this).removeClass("videoName");
//                });
                //奇艺频道suggest标题接口
//                $("input[name=videoName]").bind('input propertychange', function () {
//
//                    var videotype = $('input[name=videotype]:checked').val();
//                    if (word && videotype != -1) {
//                        $.get('http://lego.iqiyi.com/suggest/simple-video', {
//                            'word': word,
//                            'type': 'properTitle',
//                            'isMade': videotype
//                        }, function (item) {
//                            $('.cn_hide').empty();
//                            if (item.code == 'A00000') {
//                                var messages = item.data;
//                                if (messages.length) {
//                                    settings.videonameArr = [];
//                                    $.each(messages, function (index, message) {
//                                        videonameArr.push(message.properTitle);
//                                        var rhtml = '<p class="spe" onclick="put_input(\'' + message.entityId + '\',\'' + message.properTitle + '\',\'' + message.categoryId + '\',\'' + message.categoryName + '\',\'' + message.albumId + '\',\'' + message.albumDisplayName + '\')" style="margin:0px;padding-bottom:5px;cursor:pointer">' + message.properTitle + '</p>';
//                                        $('.cn_hide').append(rhtml);
//                                    })
//                                    $('.cn_hide').show();
//                                } else {
//                                    $("input[name=videoId]").val("");
//                                    $('.cn_hide').hide();
//                                }
//                            }
//                        }, 'json')
//                    }
//
//                });

                $('input[name=eTime]').blur(function () {
                    VOD.Util.fillDefaultTitle();
                })
            },
            updateDaoSetting: function () {
                var self = this;
                var settings = {
                    index: 1,
                    stime: 0,
                    etime: 0,
                    pic: 0,
                    taskid: 0,
                    lastImg: 0,
                    delList: [],
                    subData: [],
                    needDatas: [],
                    isStart: false,
                    isSetFpTime: false,
                    lb: 1,
                    firstFpTime: 0,
                    last_i: 0,   // 上次识的库索引
                    adLibList: [],
                    isOver: 1  //防止并发
                }
                if (!$('#changeBigPic').hasClass('btn-primary')) {
                    settings.fpTime = 'fp_time';
                } else {
                    settings.fpTime = 'fp_time2';
                }
                VOD.Util.updateObjectData(settings, self.dao.settings);
            },
            bindAddInfo: function () {
                $('#d_addInfo').click(function () {
                    if (VOD.Util.del_submit()) {
                        //alert('删除成功');
                        VOD.Plugin.tips("success", '删除成功');
                    }
                    $('#d_addInfo').removeAttr('disabled').html('提交');
                })
                $('#addInfo').click(function () {
                    if (VOD.Util.dot_submit()) {
                        //alert('打点成功');
                        VOD.Plugin.tips("success", '打点成功');
                    }
                    $('#addInfo').removeAttr('disabled').html('提交');
                });
            },
            bindReviewInfo: function () {
                var self = this;
                $('#reviewInfo').bind("click", function (e) {
                    var sTime = $('input[name=sTime]').val(),
                        eTime = $('input[name=eTime]').val();
                    VOD.Util.doReview(sTime, eTime, true)
                })
                $('#d_reviewInfo').bind("click", function (e) {
                    var sTime = $('input[name=d_sTime]').val(),
                        eTime = $('input[name=d_eTime]').val();
                    VOD.Util.doReview(sTime, eTime, false)
                })

            },

            bindMarkImgHandler: function () {
                var self = this;
                var settings = self.dao.settings;
                $('#makedImg').on('click', 'img,.transparent_class', function () {
                    VOD.Config.Global.isClicked = true;  // 大小图片切换滚动到当前图片用
                    if ($(this).parent().find(".layout").hasClass("red"))
                        return;
                    $('.layout').removeClass('red');
                    if ($(this).parent().find(".layout").length !== 0)
                        $(this).parent().find(".layout").addClass("red");
                    else
                        $(this).parent().append(VOD.Config.RED_LAYOUT);
                    settings.pic = settings.etime = settings.stime = $(this).parent().find('.pid').text().replace(/\s+/g, "");
                })
            },
            bindJumpSubmitHandler: function () {
                $('#jumpSubmit').click(function () {
                    var jumpType = $('select[name=jumpType]').val();
                    if (jumpType == 1) {
                        var jc = $('#jumpContent').val();
                        if (!VOD.Util.isJumpData(jc, 1)) {
                            //alert('跳转输入格式错误');
                            VOD.Plugin.tips("error", '跳转输入格式错误');
                            return false;
                        }
                        var jumpContent = jc.replace(/:/g, "-");
                        if (!$('.relative').hasClass(jumpContent)) {
                            var temStr = jumpContent.substr(jumpContent.length - 2);
                            if (temStr.length == 2 && temStr.substr(0, 1) == '0') {
                                temStr = temStr.charAt(temStr.length - 1);
                            }
                            var lasStr = parseInt(temStr);
                            if (lasStr == 0) {
                                lasStr += 10;
                            }
                            var beforeStr = jumpContent.substr(0, jumpContent.length - 2)
                            var untilStr = lasStr - 10;
                            if (untilStr < 0)
                                untilStr = 0;
                            var us
                            for (var i = lasStr; i >= untilStr; i--) {

                                if (i < 10) {
                                    us = 0 + String(i);
                                } else {
                                    us = String(i);
                                }
                                us = beforeStr + us;

                                if ($('.relative').hasClass(us)) {
                                    jumpContent = us;
                                    break;
                                }
                            }
                        }
                        if ($('.relative').hasClass(jumpContent)) {
                            $('#makedImg').scrollTop(0);
                            sTop = $('.' + jumpContent).offset().top - 100;
                            $('#makedImg').scrollTop(sTop);
                        } else {
                            //alert('没有这个时间点');
                            VOD.Plugin.tips("error", '没有这个时间点');
                        }
                    } else {
                        var jc = $('#jumpContent').val();
                        if (!VOD.Util.isJumpData(jc, 0)) {
                            //alert('跳转输入格式错误');
                            VOD.Plugin.tips("error", '跳转输入格式错误');
                            return false;
                        }
                        jumpContent = jc + '-jump';
                        if ($('.relative').hasClass(jumpContent)) {
                            $('#makedImg').scrollTop(0)
                            sTop = $('.' + jumpContent).offset().top - 100;
                            $('#makedImg').scrollTop(sTop);
                        } else {
                            //alert('没有这帧');
                            VOD.Plugin.tips("error", '没有这帧');
                        }
                    }
                })
            },
            initSuggest: function () {
                var self = this;
                var channelTypeSuggest = {
                    options: {
                        source: VOD.urlConfig.redirect,
                        renderPanel: function (handler) {
                            self.dao.getChannelType(handler)
                        },
                        select: function (event, object) {
                            console.log("trihger  channelTypeSuggest");
                            $("input[name=albumName]").removeAttr("disabled");
                            $("input[name=albumName]").val("");
                            if (object.item.id == 25 && $('input[name=videotype]:checked').val() == -1) {
                                $("#locationDiv").css('display', 'block');
                            } else {
                                $("#locationDiv").css('display', 'none');
                            }
                            VOD.Util.setCooperativePartner(object.item.value);
                            return true;
                        },
                        autoFilter: false,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            var val = this.element.val(),
                                ret = []
                            return ret;
                        },
                        getParam: function (term) {
                            var params = term.length == 0 ? {size: 100} : {word: term, size: 100}
                            var requestData = {url: VOD.Constant.thirdUrl_channel, type: "get", params: params, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },

                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["id"];
                                itemData[options.labelKey] = item["name"];
                                itemData["value"] = item["name"];
                                ret.push(itemData);
                            });
                            return ret;
                        },

                        template: function (item) {
                            return item["label"];
                        }
                    }
                }
                var albumSuggest = {
                    options: {
                        source: VOD.urlConfig.redirect,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            return [];
                        },
                        getParam: function (term) {
                            var channelId = $("input[name=categoryName]").suggest("getValue")
                            var requestData = {url: VOD.Constant.thirdUrl_album, type: "get", params: {word: term, type: "displayName", filter_EQL_channel: channelId}, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["entityId"];
                                itemData[options.labelKey] = item["displayName"];
                                itemData["value"] = item["displayName"];
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item["label"];
                        }
                    }
                }
                var locationSuggest = {
                    options: {
                        source: VOD.urlConfig.redirect,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            return [];
                        },
                        getParam: function (term) {
                            var requestData = {url: VOD.Constant.thirdUrl_locationUrl, type: "get", params: {word: term, type: "province,city", domestic: 1}, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["id"];
                                itemData[options.labelKey] = item["name"];
                                itemData["value"] = item["name"];
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item["label"];
                        }
                    }
                }

                var videoSuggest = {
                    options: {
                        source: VOD.urlConfig.redirect,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            return [];
                        },
                        validate:false,
                        getParam: function (term) {
                            var videotype = $('input[name=videotype]:checked').val();
                            $("input[name=videoName]").suggest("option", "stopSuggest", videotype == -1);
                            var requestData = {url: VOD.Constant.thirdUrl_simple_video, type: "get", params: {word: term, type: "properTitle", isMade: videotype}, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["entityId"];
                                itemData[options.labelKey] = item["properTitle"];
                                itemData["value"] = item["properTitle"];

                                itemData["videoId"] = item["entityId"] || 0;
                                itemData["videoName"] = item["properTitle"] || "";

                                itemData["categoryName"] = item["categoryName"] || "";
                                itemData["categoryId"] = item["categoryId"] || 0;

                                itemData["albumName"] = item["albumDisplayName"] || "";
                                itemData["albumId"] = item["albumId"] || 0;
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        select: function (event, object) {
                            if(  object.item.albumId > 0 ){
                                $("input[name=albumName]").suggest("setValue",{id:object.item.albumId,label:object.item.albumName})
                            }else{
                                $("input[name=albumName]").suggest("setValue","")
                            }
                            if(  object.item.videoId > 0 ){
                                $("input[name=videoName]").suggest("setValue",{id:object.item.videoId,label:object.item.videoName})
                            }else{
                                $("input[name=videoName]").suggest("setValue","")
                            }
                            if(  object.item.categoryId > 0 ){
                                $("input[name=categoryName]").suggest("setValue",{id:object.item.categoryId,label:object.item.categoryName});
                            }else{
                                $("input[name=categoryName]").suggest("setValue","")
                            }
                            $('input[name=albumName],input[name=imageId],input[name=categoryName]').attr('disabled', 'disabled');
                            return true;
                        },
                        template: function (item) {
                            return item["label"];
                        }
                    }
                }

                $("input[name=categoryName]").suggest(channelTypeSuggest.options);
                $("input[name=albumName]").suggest(albumSuggest.options);
                $("input[name=location]").suggest(locationSuggest.options);
                $("input[name=videoName]").suggest(videoSuggest.options);
                var paramsData = self.dao.getParamsData();
                if(parseInt( paramsData.locationCategory)> 0 ){
                    $("input[name=location]").suggest("setValue",{id:paramsData.locationCategory,label: decodeURI( paramsData.location)})
                }
            },
            initGrid: function () {
                var self = this;
                self.config.PageBeanFrame = VOD.Util.createPageBean();
                self.config.PageBeanAdvert = VOD.Util.createPageBean();
                self.initFrameGrid();
                self.initAdvertGrid();
            },
            initFrameGrid: function (options, callback) {
                var self = this;
                var gridConfig = self.getGridConfig(self.config.TABLE_FRAME_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$FrameGrid.jqGrid(options);
            },
            initAdvertGrid: function (options, callback) {
                var self = this;
                var gridConfig = self.getGridConfig(self.config.TABLE_ADVERT_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$AdvertGrid.jqGrid(options);
            }

        })
    }
);
define(
    '../vod/VOD.NewsEdit',['require','exports','module'],function (require, exports, module) {
        VOD.NewsEdit = function (options) {
            this.dao = VOD.Dao;
            this.task = VOD.Task;
            this.config = VOD.Config;
            this.options = options || {};

        };
        Com.inherits(VOD.NewsEdit, VOD.Edit, function (options) {
        }).extend({
            newsInit: function () {
                var self = this;
                self.initNewsEdit();
                self.initTabs();
                self.init();
                self.initLoadImage();
                self.initAlterTitleDlg();
                self.initTab3();
            },
            initNewsEdit: function () {
                $("a[action-name=save-album-smart-library]").hide();
                $("a[action-name=save-ad-smart-library]").hide();
                $("#ocr").hide();
                $("#acr").hide();
                $("#inputStartTime").attr("disabled", "disabled");
                $("#inputEndTime").attr("disabled", "disabled");
            },
            //override
            initPointTime: function () {
                var self = this;
                var paramsData = self.dao.getParamsData();
                if (paramsData.startTime == null || paramsData.endTime == null) {
                    console.log("error");
                    return;
                }
                var s_d = paramsData.startTime;
                var e_d = paramsData.endTime;
                $('#inputStartTime').val(s_d);
                $('#inputEndTime').val(e_d);
                if (s_d >= e_d) {
                    $("#submitStartTime").prop("disabled", "disabled");
                    VOD.Plugin.tips("error", '开始时间必须小于结束时间');
                    return
                }
                VOD.Util.bindDate("inputStartTime", "inputEndTime", { maxDate: e_d, maxDateTime: new Date(e_d.replace(/-/g, "/")), minDate: s_d, minDateTime: new Date(s_d.replace(/-/g, "/"))});
                $("input[name=inputStartTime]").datetimepicker("setDate", new Date(s_d.replace(/-/g, "/")));
                $("input[name=inputEndTime]").datetimepicker("setDate", new Date(e_d.replace(/-/g, "/")));
                $("#submitStartTime").prop("disabled", "disabled");
                VOD.Config.INIT_SUCCESS = true;
            },
            initHelp2: function () {
                $("#help2-dlg").dialog({
                    title: "发布系统帮助",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 600,
                    modal: true
                })
                var innerText = "";
                $.each(VOD.Config.HELP2_DATA, function (i, data) {
                    innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
                })
                $("#help2-dlg").find("tbody").html(innerText);
            },


            initTabs: function () {
                var self = this;
                $("#navDiv").tabs({active: 1});
                $("li[aria-controls=tab3]").hide();
                $("button[name=add_tab2]").hide();
                $("#navDiv").delegate("span.ui-icon-close", "click", function () {
                    $("li[aria-controls=tab3]").hide();
                    $("#tab3").hide();
                    $("#navDiv").tabs({active: 1});
                });


                $("a[href^=#tab]").bind("click", function (event) {
                    switch (event.currentTarget.id) {
                        case "ui-id-1":
                            console.log("show tab1");
                            VOD.AccurateFrame.doReset();
                            VOD.Util.clearHighLight();
                            //   self.cleanTab3();
                            break;
                        case "ui-id-2":
                            console.log("show tab2");
                           // VOD.Util.readGridSelectedFrameData();
                            $(".layout").click();
                            break;
                        case "ui-id-3":
                            $(".layout").click();
                            VOD.Util.readPublishFrameData();
                            console.log("show tab3");
                            break;
                    }
                })
            },
            initGrid: function () {
                var self = this;
                self.config.PageBeanFrame = VOD.Util.createPageBean();
                self.config.PageBeanAdvert = VOD.Util.createPageBean();
                self.config.PageBeanNews = VOD.Util.createPageBean();
                self.initFrameGrid();
                self.initAdvertGrid();
                self.initNewsGrid();
            },
            initNewsGrid: function (options, callback) {
                var self = this;
                var gridConfig = self.getGridConfig(self.config.TABLE_NEWS_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$NewsGrid.jqGrid(options);
                $("#news_pager_left").css({width: "10px"});
                var htmlArr = [];
                htmlArr.push("<button type='button' name='refresh_tab2'>刷新</button>");
                htmlArr.push("<button type='button' onclick='VOD.Util.doQuickAdd()'>添加</button>");
                htmlArr.push("<button type='button' onclick='VOD.Util.doQuickMerge()'>合并</button>");
                htmlArr.push("<button type='button' onclick='VOD.Util.doSelectedAll(true)'>全选</button>");
                htmlArr.push("<button type='button' onclick='VOD.Util.doSelectedAll(false)'>清除选中</button>");
                $(htmlArr.join("")).appendTo($("#t_news_list"));
                $("button[name=refresh_tab2]").click(function (event) {
                    $("#navDiv").tabs({active: 1});
                    $("li[aria-controls=tab3]").hide();
                    $("#tab3").hide();
                    VOD.Util.clearHighLight();
                    self.queryNews();
                })

                //doAddTempRow
                self.queryNews();
            },
            queryNews: function () {
                var self = this;
                var taskid = VOD.Dao.settings.taskid;
                if (taskid == 0) {
                    console.log("queryNews taskid = 0");
                    return;
                }
                $("#news_list").jqGrid("setGridParam", {selrow: null});
                VOD.Util.clearHighLight();
                self.dao.getNewsList({key: taskid, from_client: true, index: 0, type: 1, offset: 100 }, function (data) {
                    if (data != null && data.list != null) {
                        var formatArr = [];
                        self.dao.settings.reg_last_id = 0;
                        var regId = self.dao.settings.reg_last_id;
                        var accurateFrameArr = [];
                        $.each(data.list, function (i, element) {
                            regId++;
                            accurateFrameArr.push(element.video_list[element.video_list.length - 1]);
                            formatArr.push({ title: element.text, sTime: element.video_list[0], eTime: element.video_list[element.video_list.length - 1], pic: element.cover, id: element.id, regId: regId,checked:false })
                        })
                        VOD.AccurateFrame.saveAccurateFrameArr(accurateFrameArr);
                        self.dao.settings.reg_last_id = regId
                        var lastSortSource = self.config.PageBeanNews.getSource();
                        if (lastSortSource.length > 0) {
                            formatArr = VOD.Util.doSourceMerge( lastSortSource ,formatArr);
                        }
                        self.config.PageBeanNews.setNewData(formatArr, 100);
                        VOD.Util.updateInfoComplete($("#inputEndTime").val(), data.list.length);
                    } else {
                        VOD.Util.updateInfoComplete($("#inputEndTime").val(), 0);
                        self.config.PageBeanNews.setNewData([], 100);
                    }
                    var retValue = self.config.PageBeanNews.getCur();
                    self.options.$NewsGrid.clearGridData();
                    self.options.$NewsGrid[0].addJSONData(retValue);

                });
            },

            initInterValTask: function () {
                var self = this;
                setInterval(self.task.getData, 5000);   // 获取图片数据

                //setInterval(getCate,20000);
                //      setInterval(self.task.getSty2, 19000);   // 智能识别数据
                VOD.Config.Global.sty2Data.list = [];
                //     setInterval(self.task.getOcr, 23000);
                //    setInterval(self.task.getAcr, 11000);
            },

            initAlterTitleDlg: function () {
                $("#alter_title-dlg").dialog({
                    title: "请选择该新闻标题",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 350,
                    //   minHeight:250,
                    modal: true
                })
                $("button[name=alter_title-ok]").bind("click", function (e) {
                    if (VOD.Util.isTab3Show()) {
                        VOD.Util.updateNewsFormData();
                    }
                    VOD.Util.updateNewsGridRowData();
                    $("#alter_title-dlg").dialog("close");
                });
                $("button[name=alter_title-cancel]").bind("click", function (e) {
                    $("#alter_title-dlg").dialog("close");
                });
            },
            initLoadImage: function () {
                if (VOD.Config.INIT_SUCCESS) {
                    var queryStringObj = VOD.Util.getUrlParams();
                    if (VOD.Plugin.Validate.checkDateFormat(queryStringObj["startTime"]) && VOD.Plugin.Validate.checkDateFormat(queryStringObj["endTime"])) {
                        $("input[name=inputStartTime]").datetimepicker("setDate", new Date(queryStringObj["startTime"].replace(/-/g, "/")));
                        $("input[name=inputEndTime]").datetimepicker("setDate", new Date(queryStringObj["endTime"].replace(/-/g, "/")));
                        $('#submitStartTime').click();
                    }
                }
            },
            initTab3: function () {
                var self = this;
                self.initSuggest2();
                $("button[name=tab3_title_select]").click(function (event) {
                    VOD.Util.AlterTitle(parseInt($("span[name=tabName]").html().replace(/序号|发布/g, "")));
                })
                $("button[name=tab3_review]").bind("click", function (event) {
                    var sTime = $("input[name=tab3_inpoint]").val();
                    var eTime = $("input[name=tab3_outpoint]").val();
                    VOD.Util.doReview(sTime, eTime, false)
                })
                VOD.Util.limitWordCount($("input[name=tab3_title]"), 43, null, null, function (length) {
                    $("span.leftWordsCount2").text(length);
                });
                $("button[name=tab3_submit]").bind("click", function (event) {
                    VOD.Util.news_submit();
                })
                $("input[name=tab3_outpoint]").bind("input propertychange", function (event) {
                    VOD.Util.updateTab3Check({ value: $("input[name=tab3_outpoint]").val(), key: "et"})
                })
                $("input[name=tab3_inpoint]").bind("input propertychange", function (event) {
                    VOD.Util.updateTab3Check({ value: $("input[name=tab3_inpoint]").val(), key: "st"})
                })
                $("input[name=tab3_imageId]").bind("input propertychange", function (event) {
                    VOD.Util.updateTab3Check({ value: $("input[name=tab3_imageId]").val(), key: "pic" })
                })
            },
            initSuggest2: function () {
                var self = this;
                var channelTypeSuggest = {
                    options: {
                        source: VOD.urlConfig.redirect,
                        renderPanel: function (handler) {
                            self.dao.getChannelType(handler)
                        },
                        select: function (event, object) {
                            console.log("initSuggest2  channelTypeSuggest");
                            $("input[name=tab3_albumName]").removeAttr("disabled");
                            $("input[name=tab3_albumName]").val("");
                            VOD.Util.setCooperativePartner_tab3(object.item.value);
                            return true;
                        },
                        autoFilter: false,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            var val = this.element.val(),
                                ret = []
                            return ret;
                        },
                        getParam: function (term) {
                            var params = term.length == 0 ? {size: 100} : {word: term, size: 100}
                            var requestData = {url: VOD.Constant.thirdUrl_channel, type: "get", params: params, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },

                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["id"];
                                itemData[options.labelKey] = item["name"];
                                itemData["value"] = item["name"];
                                ret.push(itemData);
                            });
                            return ret;
                        },

                        template: function (item) {
                            return item["label"];
                        }
                    }
                }
                var albumSuggest = {
                    options: {
                        source: VOD.urlConfig.redirect,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            return [];
                        },
                        getParam: function (term) {
                            var channelId = $("input[name=tab3_categoryName]").suggest("getValue")
                            var requestData = {url: VOD.Constant.thirdUrl_album, type: "get", params: {word: term, type: "displayName", filter_EQL_channel: channelId}, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["entityId"];
                                itemData[options.labelKey] = item["displayName"];
                                itemData["value"] = item["displayName"];
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item["label"];
                        }
                    }
                }
                $("input[name=tab3_categoryName]").suggest(channelTypeSuggest.options);
                $("input[name=tab3_albumName]").suggest(albumSuggest.options);
            }

        })
    }
);
define(
    '../vod/VOD.Player',['require','exports','module'],function (require, exports, module) {
        VOD.Player = (function () {
            var playOnePosition = {
                left: '',
                top: ''
            }
            var flashvars = {};
            var textArr = [];
            var params = {};
            params.scale = "noscale";
            params.salign = "tl";
            params.wmode = "transparent";
            params.swliveconnect = "true";
            params.allowfullscreen = "true";
            params.allowscriptaccess = "always";
            params.allownetworking = "all";
            params.bgcolor = "#000000";
            var player = {};
            player.swf = "http://www.iqiyi.com/player/20130702143439/expressInstall.swf";
            player.version = "10.0.0";
            player.liveEidtUrl = "/epg/swfs/liveEidt.swf";
            player.ScreenPrintUrl = "/epg/swfs/ScreenPrint.swf?20156291103";

            var settings = VOD.Dao.settings;
            // 左侧播放器
            function initLeftPlayer() {
                var attributes = {};
                attributes.id = "flash";
                attributes.pause = "暂停";
                swfobject.embedSWF(player.liveEidtUrl, "ppsLiveDiv", "100%", "300", player.version, player.swf, flashvars, params, attributes);
            }

            // 单张图片视频预览播放器
            function initPicPlayer() {
                var _attributes = {};
                _attributes.id = "flashOne";
                _attributes.pause = "暂停";
                swfobject.embedSWF(player.liveEidtUrl, "ppsLiveOneFrame", "100%", "100%", player.version, player.swf, flashvars, params, _attributes);
            }

// 起止帧精确化播放器
            function initFramePlayer() {
                var _attributes = {};
                _attributes.id = "accurateStartEndFrame";
                _attributes.pause = "暂停";
                params.scale = "Showall";
                swfobject.embedSWF(player.ScreenPrintUrl, "accurateStartEndDiv", "100%", "100%", player.version, player.swf, flashvars, params, _attributes);
            }

            //搭建js与flash互通的环境
            function thisMovie(movieName) {
                if (navigator.appName.indexOf("Microsoft") != -1) {
                    return window[movieName];
                } else {
                    return document[movieName];
                }
            }

            function shuffle(inputArr) {
                var valArr = [],
                    k = '';

                for (k in inputArr) { // Get key and value arrays
                    if (inputArr.hasOwnProperty(k)) {
                        valArr.push(inputArr[k]);
                    }
                }
                valArr.sort(function () {
                    return 0.5 - Math.random();
                });

                return valArr;
            }

            function playAll(allList) {
                var text = {};
                text.textContent = '';
                textArr.length = 0;
                var k = {};
                for (k in allList.list) {
                    textArr.push(allList.list[k].url);
                }
                text.textContent = textArr.join('\r\n');
                thisMovie('flash').load(JSON.stringify(allList));
            }

            function playOne(allList) {
                var text = {};
                text.textContent = '';
                textArr.length = 0;
                var k = {};
                for (k in allList.list) {
                    textArr.push(allList.list[k].url);
                }

                text.textContent = textArr.join('\r\n');

                thisMovie('flashOne').load(JSON.stringify(allList));
                $("#play-one").css({
                    top: playOnePosition.top,
                    left: playOnePosition.left
                });
            }

            function updatePosition(options) {
                playOnePosition.left = options.left;
                playOnePosition.top = options.top;
            }

            function initPlayer() {
                initLeftPlayer();
                initPicPlayer();
                initFramePlayer();
            }

            //播放功能
            function view(viewTime) {
                var listUrl = VOD.Dao.getDotData().listUrl;
                //从刘志红那里取json列表
                $.get(listUrl, {
                    'key' : VOD.Dao.settings.taskid,
                    'from_client' : true,
                    'index' : viewTime,
                    'type' : 0,
                    'offset' : 100
                }, function (data) {
                    $('#allList').data(data);
                    playAll(data);
                }, 'json');
                //传给王鹏
            }

            //播放1帧
            function viewOne(viewTime) {
                //从刘志红那里取json列表
                var listUrl = VOD.Dao.getDotData().listUrl;
                $.get(listUrl, {
                    'key': VOD.Dao.settings.taskid,
                    'from_client': true,
                    'index': viewTime,
                    'type': 0,
                    'offset': 1
                }, function (data) {
                    $('#allList').data(data);
                    playOne(data);
                }, 'json');
                //传给王鹏
            }

            function splitData(stime, etime, needRemoveDelData) {
                stime = parseInt(stime);
                etime = parseInt(etime);
                var settings = VOD.Dao.settings;
                settings.subData = [];
                var needDatas = [];
                for (i = stime; i <= etime; i++) {
                    needDatas.push(i);
                }
                //console.log(needDatas);
                //console.log(delList);
                if (needRemoveDelData && settings.delList.length) {
                    $.each(settings.delList, function (k, v) {
                        v = parseInt(v);
                        if (stime <= v && v <= etime) {
                            for (var i = 0; i < needDatas.length; i++) { //删除v的元素
                                if (needDatas[i] == v) {
                                    needDatas.splice(i, 1);
                                    break;
                                }
                            }
                        }
                    })
                }
                settings.subData = needDatas;
                //console.log(subData);
            }

            function review() {
                if (!settings.subData.length) {
                    //alert('请先打点,再预览!');
                    VOD.Plugin.tips("error", '请先打点,再预览!');
                    return false;
                }
                var reviewData = {
                    'list': []
                };
                //console.log(subData);
                $.each(settings.subData, function (k, v) {
                    var src = $('#img-' + v).attr('src');
                    if (!src) {
                        //alert('数据为空不能预览!');
                        return false;
                    }
                    reviewData.list.push( {url: src.replace(/jpg/g, "flv"),name: k+"" });
                })

                playAll(reviewData);
            }

            //打好的点预览
            var reviewOne = function (s, e, vType) {
                var reviewOneData = {
                    'list': []
                };
                s = parseInt(s);
                e = parseInt(e);
                var src , flv, obj;
                for (var i = s; i <= e; i++) {
                    if (settings.delList.length && vType != "删除") {
                        var isNeed = true;
                        for (var j = 0; j <= settings.delList.length; j++) {
                            var v = settings.delList[j];
                            if (i == v) {
                                isNeed = false;
                            }
                        }
                        if (isNeed) {
                            src = $('#img-' + i).attr('src');
                            obj = {url: src.replace(/jpg/g, "flv"),name: i+"" }
                            reviewOneData.list.push(obj);
                        }
                    } else {
                        src = $('#img-' + i).attr('src');
                        obj = {url: src.replace(/jpg/g, "flv"),name: i+"" }
                        reviewOneData.list.push(obj);
                    }
                }
                //console.log(reviewOneData);
                playAll(reviewOneData);
            }

            function nofind(img_url){
                var img=event.srcElement;
                img.src=img_url;
            }

            return {
                initPlayer: initPlayer,
                playAll: playAll,
                playOne: playOne,
                updatePosition: updatePosition,
                viewOne: viewOne,
                view:view,
                nofind:nofind,
                splitData:splitData,
                review:review,
                reviewOne:reviewOne
            }
        })()
    }
);
define(
    '../vod/VOD.NewsHighlight',['require','exports','module'],function (require, exports, module) {
        VOD.NewsHighlight = (function () {
            var lastOption = null;
            var defaults = {
                st: 0,
                et: 0,
                pic: 0,
                color: '',
                bgColor: '',
                removeColor: ''
            };

            function setHighLight(options) {
                if (lastOption != null) {
                    lastOption.removeColor = true;
                    addBackgroundColor(lastOption);
                    $('.p-l-' + lastOption.id).remove();
                    $('.p-r-' + lastOption.id).remove();
                    $('.p-middle-' + lastOption.id).remove();
                }
                if (options != null) {
                    lastOption = $.extend({}, defaults, options);
                    addBackgroundColor(lastOption)
                    addInOutMark(lastOption);
                }else{
                    lastOption = null;
                }
            }


            function addInOutMark(options) {
                var bigMark = '';
                if ($("#changeBigPic").hasClass('btn-primary'))
                    bigMark = 'in-out-mark-b';

                var str = '<div class="absolute in-out-mark-s ' + bigMark + ' p-l p-l-' + options.id + '">' + options.id + '<br>入点</div>';
                $('#img-' + options.st).after(str);
                str = '<div class="absolute in-out-mark-s ' + bigMark + ' p-r p-r-' + options.id + '">' + options.id + '<br>出点</div>';
                $('#img-' + options.et).after(str);

                str = '<div class="absolute in-out-mark-s ' + bigMark + ' p-middle p-middle-' + options.id + '">' + options.id + '<br>封面</div>';
                $('#img-' + options.pic).after(str);
            }

            function addBackgroundColor(options) {
                for (var i = options.st; i <= options.et; i++) {
                    if (!options.removeColor) {
                        $('#img-' + i).addClass(options.color).addClass(options.bgColor);
                    } else {
                        $('#img-' + i).removeClass(options.color).removeClass(options.bgColor);
                    }
                }
            }

            function validCheck() {
                if (lastOption != null) {
                    var findData = VOD.Config.PageBeanNews.findData("regId", parseInt(lastOption.id));
                    if (findData != null) {
                        return parseInt($(".red").parent().find(".pid").html());
                    }
                }
                return null;
            }

            function setNewStart(value) {
                var newstart = value == null ? validCheck() : value;
                var maxValue = parseInt($('#picNum').text())  - 1;

                if (newstart != null) {
                    if (newstart >= maxValue) {
                        console.log("wrong  st " + newstart)
                        return;
                    }
                    if (newstart != lastOption.st) {
                        var newOptions = $.extend(true, {}, lastOption, { st: newstart});
                        var updateObj = {id: lastOption.id, sTime: newstart};
                        if (newstart > lastOption.pic) {
                            updateObj.pic = newstart;
                            newOptions.pic = newstart;
                        }
                        if (newstart >= lastOption.et) {
                            updateObj.eTime = newstart + 1;
                            newOptions.et = newstart + 1;
                        }
                        VOD.AccurateFrame.updateAccurateFrame({head: '', headSetted: false})
                        VOD.Util.updateGridNews(updateObj)
                        VOD.Util.updateTab3Form(updateObj)
                        setHighLight(newOptions);
                    }
                }
            }

            function setNewEnd(value) {
                var newEnd = value == null ? validCheck() : value;
                if (newEnd != null) {
                    if (newEnd == 0) {
                        console.log("wrong et " + newEnd);
                        return;
                    }
                    if (newEnd != lastOption.et) {
                        var newOptions = $.extend(true, {}, lastOption, { et: newEnd});

                        var updateObj = {id: lastOption.id, eTime: newEnd};
                        if (newEnd < lastOption.pic) {
                            updateObj.pic = newEnd;
                            newOptions.pic = newEnd;
                        }
                        if (newEnd <= lastOption.st) {
                            updateObj.sTime = newEnd - 1;
                            newOptions.st = newEnd - 1;
                        }
                        VOD.AccurateFrame.updateAccurateFrame({end: '', endSetted: false})
                        VOD.Util.updateGridNews(updateObj)
                        VOD.Util.updateTab3Form(updateObj)
                        setHighLight(newOptions);
                    }
                }
            }


            function setNewImage(value) {
                var image = value == null ? validCheck() : value;
                if (image != null) {
                    if (image != lastOption.pic) {
                        var newOptions = $.extend(true, {}, lastOption, { pic: image});
                        var updateObj = {id: lastOption.id, pic: image};
                        if (lastOption.st > image) {
                            updateObj.sTime = image;
                            newOptions.st = image;
                            VOD.AccurateFrame.updateAccurateFrame({head: '', headSetted: false})
                        } else if (lastOption.et < image) {
                            updateObj.eTime = image;
                            newOptions.et = image;
                            VOD.AccurateFrame.updateAccurateFrame({end: '', endSetted: false})
                        }
                        VOD.Util.updateGridNews(updateObj)
                        VOD.Util.updateTab3Form(updateObj)
                        setHighLight(newOptions);
                    }
                }
            }

            function getLastOption() {
                if (lastOption == null) {
                    return null;
                }
                return $.extend({}, lastOption);
            }

            function setNewOption(options) {
                switch (options.key) {
                    case "st":
                        setNewStart(options.value);
                        break;
                    case "et":
                        setNewEnd(options.value);
                        break;
                    case "pic":
                        setNewImage(options.value)
                        break;
                }
            }


            return {
                setHighLight: setHighLight,
                setNewStart: setNewStart,
                setNewEnd: setNewEnd,
                setNewImage: setNewImage,
                getLastOption: getLastOption,
                setNewOption: setNewOption
            }
        })()
    }
);
define(
    '../vod/VOD.AccurateFrame',['require','exports','module'],function (require, exports, module) {
        VOD.AccurateFrame = (function () {
            var markedFrameArr = [];
            var adAccurate = {};
            var params = ["fragment-l", "fragment-r", "ad-l", "ad-r"];
            var accurateFrame = {
                'head': '', //打点精确化起始帧
                'end': '', //打点精确化结束帧
                'endSetted': false,
                'headSetted': false
            }
            //搭建js与flash互通的环境
            function thisMovie(movieName) {
                if (navigator.appName.indexOf("Microsoft") != -1) {
                    return window[movieName];
                } else {
                    return document[movieName];
                }
            }

            function doReset() {
                accurateFrame = {
                    'head': '', //打点精确化起始帧
                    'end': '', //打点精确化结束帧
                    'endSetted': false,
                    'headSetted': false
                }
            }


            function accurateStartEndRemove() {
                var frameId = thisMovie('accurateStartEndFrame').get_select_index();

                if (frameId == -1) {
                    frameId = '';
                }
                if (VOD.Util.isTab2Show() || VOD.Util.isTab3Show()) {
                    if ($('.red').parent().find('.p-l').length > 0) {
                        accurateFrame.head = frameId;

                        if (accurateFrame.head){
                            accurateFrame.headSetted = true;
                        }
                    }
                    if ($('.red').parent().find('.p-r').length > 0) {
                        accurateFrame.end = frameId;

                        if (accurateFrame.end){
                            accurateFrame.endSetted = true;
                            VOD.Util.bindFrameData(accurateFrame );
                        }

                    }
                } else {
                    if ($('.red').hasClass('fragment-l')) {
                        accurateFrame.head = frameId;

                        if (accurateFrame.head)
                            accurateFrame.headSetted = true;
                    }
                    else if ($('.red').hasClass('fragment-r')) {
                        accurateFrame.end = frameId;

                        if (accurateFrame.end)
                            accurateFrame.endSetted = true;
                    }
                    else if ($('.red').hasClass('ad-l')) {
                        adAccurate[$('input[name=d_sTime]').val()] = frameId;

                    }
                    else if ($('.red').hasClass('ad-r')) {
                        adAccurate[$('input[name=d_eTime]').val()] = frameId;
                    }
                }

                $('#accurateStartEndOutDiv').css({
                    'left': '-10000px',
                    'top': '-10000px'
                });
            }

            // 打点精确化数据加载
            function accurateStartEndPlay(imgSrc) {
                var analysis = VOD.Dao.getDotData().analysis;
                $('#accurateStartEndOutDiv').css({
                    'left': '0px',
                    'top': '0px'
                });
                thisMovie('accurateStartEndFrame').change_flv_url(analysis + "?file=" + imgSrc + "&from_client=true");
            }

            function getAccurateFrame() {
                return accurateFrame;
            }

            function updateAccurateFrame(options) {
                VOD.Util.updateObjectData(options, accurateFrame)
            }

            function getAdAccurate() {
                return adAccurate;
            }

            // has marked ad will be removed
            function adTipRemove() {
                $('.ad-l').remove();
                $('.ad-r').remove();
            }

            // has marked fragment will be removed
            function fgTipRemove() {
                $('.fragment-l').remove();
                $('.fragment-r').remove();
            }

            function handler_keyCodeQ() {
                var selected = $(".red");
                if (VOD.Util.isTab2Show() || VOD.Util.isTab3Show()) {
                    var lastOption = VOD.NewsHighlight.getLastOption();
                    if (lastOption != null) {
                        var current = parseInt($(".red").parent().find(".pid").text());
                        if (lastOption.st == current || lastOption.et == current || lastOption.pic == current) {
                            console.log("keycodeq," + current);
                            accurateStartEndPlay($("#img-" + current).attr("src"));
                        }
                    }
                } else {
                    $.each(params, function (i, element) {
                        if (selected.hasClass(element)) {
                            accurateStartEndPlay($('.' + element).parent().find("img").attr("src"));
                            return false;
                        }
                    })
                }
            }

            function saveAccurateFrameArr(dataArr) {
                markedFrameArr = dataArr
            }

            function isMarkedFrame(eTime) {
                return markedFrameArr.indexOf(eTime) != -1;
            }
            function readFrameData(frameData){
                accurateFrame = $.extend(true,{},frameData);
            }
            return {
                accurateStartEndPlay: accurateStartEndPlay,
                accurateStartEndRemove: accurateStartEndRemove,
                getAccurateFrame: getAccurateFrame,
                updateAccurateFrame: updateAccurateFrame,
                getAdAccurate: getAdAccurate,
                adTipRemove: adTipRemove,
                fgTipRemove: fgTipRemove,
                handler_keyCodeQ: handler_keyCodeQ,
                doReset: doReset,
                saveAccurateFrameArr: saveAccurateFrameArr,
                isMarkedFrame: isMarkedFrame,
                readFrameData:readFrameData
            }
        })()
    }
);
define(
    '../vod/VOD.Advert',['require','exports','module'],function (require, exports, module) {
        VOD.Advert = (function () {
            var st = 1;
            var sLayer = '<div class="transparent_class"></div>';
            var FFSq = [];
            var add = [];
            var del = [];
            function DealFFSq(id) {
                for (var i in FFSq) {
                    if (FFSq[i] == id) {
                        FFSq.splice(i, 1);
                        return;
                    }
                }
                FFSq.push(id);
            }

            function popFFSq(id) {
                for (var i in FFSq) {
                    var temp = FFSq[i].split('|')
                    if (temp[0] == id) {
                        FFSq.splice(i, 1);
                        return;
                    }
                }
            }

            var tc = '';

            function add_firt_frame(obj, layer) {
                tc = $(obj).parents(".text-center");
                if ($(tc).find(".transparent_class").attr("class") == 'transparent_class') {
                    $(tc).find(".transparent_class").remove();
                } else {
                    $(tc).find('.btn-group').before(layer);
                }

                var id = $(tc).find("span").text();

                DealFFSq(id);
            }

            function layer(type) {
                var sLayer = '';
                if (type == 'ad')
                    sLayer = '<div class="transparent_class background-blue"></div>';
                else if (type == 'perspectiveImg')
                    sLayer = '<div class="transparent_class background-red"></div>';
                return sLayer;
            }

            //去除广告数据
            function      removeAdData   (stime, etime, needRemoveDelData) {
                stime = parseInt(stime);
                etime = parseInt(etime);
                //subData = [];
                var settings = VOD.Dao.settings;
               var  needDatas = [];
                for (i = stime; i <= etime; i++) {
                    needDatas.push(i);
                }

                if (needRemoveDelData && settings.delList.length) {
                    $.each(settings.delList, function (k, v) {
                        v = parseInt(v);
                        if (stime <= v && v <= etime) {
                            for (var i = 0; i < needDatas.length; i++) { //删除v的元素
                                if (needDatas[i] == v) {
                                    needDatas.splice(i, 1);
                                    break;
                                }
                            }
                        }
                    })
                }
                return needDatas;
            }

            var identifyImgOptType = {
                1: {
                    "dropList": {
                        "ad": "标记为广告",
                        "perspectiveImg": "标记为片头"
                    },
                    "desc": ""
                }, // 手动标记列表 标记 1 -> 2
                2: {
                    "dropList": {
                        "cancel": "取消标记"
                    },
                    "desc": "手动标记,待提交"
                }, // 手动标记取消 取消 2 -> 1 提交已表示帧入库 2 -> 3
                3: {
                    "dropList": {
                        "del": "从库中删除标记"
                    },
                    "desc": "已提交"
                }, // 手动标记删除 从库中删除标记触发 3 -> 4
                4: {
                    "dropList": {
                        "cancel": "取消删除"
                    },
                    "desc": "删除标记,待提交"
                }, // 手动标记删除提交 取消 4->3 提交已表示帧入库->7
                5: {
                    "dropList": {
                        "del": "从库中删除标记"
                    },
                    "desc": "自动标记"
                }, // 删除自动标记  删除自动标记触发->6
                6: {
                    "dropList": {
                        "cancel": "取消删除"
                    },
                    "desc": "删除自动标记,待提交"
                }, // 删除自动标记提交 取消->5 提交已表示帧入库->7
                7: {
                    "dropList": {},
                    "desc": "删除标记,已提交"
                }
            }

// 获取下一个状态
            function getNextState(num, opt) {
                var rt = 0;
                if (num == 1)
                    rt = 2;
                else if (num == 2 && opt == 'cancel')
                    rt = 1;
                else if (num == 2 && opt == '')
                    rt = 3;
                else if (num == 3)
                    rt = 4;
                else if (num == 4 && opt == 'cancel')
                    rt = 3;
                else if (num == 4 && opt == '')
                    rt = 7;
                else if (num == 5)
                    rt = 6;
                else if (num == 6 && opt == 'cancel')
                    rt = 5;
                else if (num == 6 && opt == '')
                    rt = 7;
                return rt;
            }

// 识别操作类型产生
            function identifyImgOpt(num) {
                var li = desc = '';
                var desc = identifyImgOptType[num]['desc'];
                if (num == 7) {
                    num = 1;
                    desc = identifyImgOptType[7]['desc'];
                }

                if (identifyImgOptType[num]['dropList'] != '') {
                    for (var i in identifyImgOptType[num]['dropList']) {
                        li += '<li><a href="javascript:void(0);" onclick="VOD.Advert.perspectiveOpt(this)" mark-opt="' + i + '" data-state="' + num + '">' + identifyImgOptType[num]['dropList'][i] + '</a></li>'
                    }
                }

                return {
                    "li": li,
                    "desc": desc
                }
            }

            var chars = ['0', '1', '2'];

            function generateMixed(n) {
                var res = "";
                for (var i = 0; i < n; i++) {
                    var id = Math.ceil(Math.random() * 3);
                    res += chars[id];
                }
                return res;
            }

            function changState(obj) {
                var $this = $(obj + ">li:first>a:first");
                var num = $this.attr('data-state');
                //mark = $this.attr('mark-opt');

                var nextState = getNextState(num, '');
                var opt = identifyImgOpt(nextState);

                var dropList = $this.parents(".dropList");
                $(dropList).html(opt.li);

                $(dropList).parents(".text-center").find(".desc").text(opt.desc);

                if (nextState == 1 || nextState == 7) {
                    $(dropList).parents(".text-center").find(".transparent_class").remove();
                }

            }

            function perspectiveOpt(obj) {
                var $this = $(obj);
                var num = $this.attr('data-state');
                var mark = $this.attr('mark-opt');
                var nextState = getNextState(num, mark);
                var opt = identifyImgOpt(nextState);

                var dropList = $this.parents(".dropList");
                $(dropList).html(opt.li);

                $(dropList).parents(".text-center").find(".desc").text(opt.desc);

                var lye = layer(mark);
                if (lye != '') {
                    $(dropList).parents(".text-center").find(".transparent_class").remove();
                    $(dropList).parents(".text-center").find('.btn-group').before(lye);
                }

                if (nextState == 1 || nextState == 7) {
                    $(dropList).parents(".text-center").find(".transparent_class").remove();
                }

                var id = $(dropList).parents(".text-center").find("span").text();

                //  加入添加
                if (nextState == 2)
                    FFSq.push(id + '|add');
                else if (nextState == 4 || nextState == 6) //  加入删除
                    FFSq.push(id + '|del');

                //  加入取消操作的图下
                if (nextState == 1 || nextState == 3 || nextState == 5)
                    popFFSq(id);

                //console.log(FFSq);

                if (mark == 'ad') {
                }
                else if (mark == 'perspectiveImg') {
                }

            }

            function FFSumbit() {
               var taskid = VOD.Dao.settings.taskid;
               var d_type = $('input[name=d_imgType]').val();
                if (taskid < 1) {
                    //alert('任务ID为空,不能提交!');
                    VOD.Plugin.tips("error", "任务ID为空,不能提交!");
                    return false;
                }

                if (!FFSq.length) {
                    //alert('请先标记图片再提交!');
                    VOD.Plugin.tips("error", "请先标记图片再提交");
                    return false;
                }
                add = [];
                del = [];
                var sListAdd  = '[', sListDel = '[';

                for (var i = 0; i < FFSq.length; i++) {
                    var temp = FFSq[i].split('|')
                    if (temp[1] == 'add') {
                        add.push(temp[0]);
                        sListAdd += temp[0] + ',';
                    } else if (temp[1] == 'del') {
                        del.push(temp[0]);
                        sListDel += temp[0] + ',';
                    }
                }

                if ((sListAdd.length - 1) != 0)
                    sListAdd = sListAdd.substring(0, sListAdd.length - 1); //去除逗号
                sListAdd += ']';

                if ((sListDel.length - 1) != 0)
                    sListDel = sListDel.substring(0, sListDel.length - 1); //去除逗号
                //console.log(sListDel);
                sListDel += ']';
                /*
                 if(add.length!==0)
                 sListAdd='无添加';

                 if(del.length!==0)
                 sListDel='无删除';
                 */
                // sList = sList.substring(0,sList.length-1);//去除逗号
                // sList += ']';

                if (confirm('广告标示图片添加: ' + sListAdd + "\n" + '广告标示图片删除: ' + sListDel) == false){
                    return;
                }


                var actionType = ['add', 'del'];
                var sList = null;
                var paramsData = VOD.Dao.getParamsData();
                var dotData = VOD.Dao.getDotData();
                for (var j = 0; j < actionType.length; j++) {
                    if (actionType[j] == 'add') {
                        if (add.length == 0)
                            continue;
                        sList = sListAdd;
                    } else if (actionType[j] == 'del') {
                        if (del.length == 0)
                            continue;
                        sList = sListDel;
                    }

                    var pData = {
                        'code':dotData.channel_name,
                        'key': taskid,
                        'list': sList,
                        'imgtype': 1,
                        'from_client': true,
                        'action': actionType[j]
                    };

                    $.ajax({
                        type: "post",
                        url: dotData.adUrl,
                        data: pData,
                        success: function (data) {
                            if (data.error != 0) {
                                //alert(data.error);
                                VOD.Plugin.tips("error", data.error);
                                return false;
                            } else {
                            }
                        },
                        dataType: "json",
                        error: function () {
                            //alert('网络错误');
                            VOD.Plugin.tips("error", '网络错误');
                        }
                    });
                }

                for (var k in add) { //console.log(add[k]);
                    changState("#ul-position-" + add[k]);

                }
                add = [];

                for (var k in del) {
                    changState("#ul-position-" + del[k]);

                }

                del = [];

                //alert('提交成功');
                VOD.Plugin.tips("success", '提交成功');
                //add = del = 0;
                FFSq = [];
            }

            function clearCache(){
                FFSq = [];
                add = [];
                del = [];
            }

            function addAd2Queue  (dataSubmit) {
                for (var i = parseInt(dataSubmit.sTime); i <= dataSubmit.eTime; i++) {
                    VOD.Dao.settings.push(i);
                }
                var uniqueArr = [];
                $.each( VOD.Dao.settings, function (i, el) { //去重复
                    if ($.inArray(el, uniqueArr) === -1)
                        uniqueArr.push(el);
                });
                VOD.Dao.settings.delList = uniqueArr;
            }
            //去除广告数据
              function removeUnselectedData(options) {

              var  needDatas = [];

                if (!options)
                    return;

                $.each(options.split(','), function (i, v) {
                    var frameNumberArr = v.split('_');
                    for (i = parseInt(frameNumberArr[0]); i <= parseInt(frameNumberArr[1]); i++) {
                        needDatas.push(i);
                    }
                });

                return needDatas;
            }
            return {
                DealFFSq: DealFFSq,
                popFFSq: popFFSq,
                identifyImgOptType: identifyImgOptType,
                layer: layer,
                add_firt_frame: add_firt_frame,
                perspectiveOpt: perspectiveOpt,
                clearCache:clearCache,
                addAd2Queue:addAd2Queue,
                removeAdData:removeAdData,
                removeUnselectedData:removeUnselectedData
            }
        })()
    }
);
/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 *
 * @file:   Program.js
 * @path:   js-src/album/
 * @author: karkarrotxu@qiyi.com
 * @date:   2016-03-01
 */
define(
    '../vod/VOD.Task',['require','exports','module'],function (require, exports, module) {
        VOD.Task = (function () {
            var settings = VOD.Dao.settings;
            var dotData = VOD.Dao.getDotData();
            var global = VOD.Config.Global;

            var g_mutex = 0; // 防止数据不一致
            var g_ocrList = []; // ocr 识别出的title数据
            var g_aMutex = 0; // 防止数据不一致
            var g_acrList = []; // ocr 识别出的title数据

            var getData = function () {
                $('#addInfo,#d_addInfo').removeAttr('disabled').html('提交');

                if (settings.isOver == 0) {
                    return false;
                }
                var listUrl = dotData.listUrl;
                if (settings.taskid > 0 && settings.isStart) {
                    settings.isOver = 0
                    $.ajax({
                        type: "get",
                        url: listUrl,
                        data: {
                            'key': settings.taskid,
                            'from_client': true,
                            'index': settings.lastImg,
                            'type': 1,
                            'offset': 100
                        },
                        success: function (data) {
                            settings.isOver = 1 //防止并发
                            if (data.list.length) {
                                var li = '';
                                var sty = VOD.Config.Global.picWH;
                                var thisFpTime = "";
                                $.each(data.list, function (i, value) {
                                    var fp_time = value.fp;
                                    VOD.Config.Global.fp_pos = fp_time.lastIndexOf('/') + 1;
                                    fp_time = fp_time.substr(VOD.Config.Global.fp_pos, 10);
                                    if (!settings.isSetFpTime) {
                                        settings.firstFpTime = parseInt(fp_time);
                                        thisFpTime = '00:00:00';
                                    } else {
                                        var tmpFpTime = (parseInt(fp_time) - settings.firstFpTime);
                                        thisFpTime = VOD.Util.getDataByNum(tmpFpTime);
                                    }
                                    //////////////////////////////////////////////////////////////////////////////////////////

                                    var s = '<div class="text-center relative ' + thisFpTime.replace(/:/g, "-") + ' ' + value.id + '-jump" id="cate-' + value.vid + '">'
                                        + '<img class="fragment-img" id="img-' + value.id + '" src="' + value.fp + '"  ondblclick="VOD.Util.dl_img_click(event, \'' + value.id + '\');" onerror="VOD.Player.nofind(\'' + value.fp + '\');"' + sty + ' />'
                                        + '<div class="absolute ' + settings.fpTime + '">' + thisFpTime + '</div><br/>'
                                        + '<span class="pid">' + value.id + '</span>'
                                        + '</div>';
                                    //////////////////////////////////////////////////////////////////////////////////
                                    if ( (global.smallPic&&settings.lb % settings.linePicNum == 0) || (!global.smallPic &&settings.lb % settings.linePicNum == 0) ) {
                                        s += '<div class="clearfix breakWord">&nbsp;</div>';
                                    }

                                    $('#makedImg').append(s);
                                    //出来第一张图的时候计算几张图片一行
                                    if (!settings.isSetFpTime) {
                                        VOD.Util.getLineWidth();
                                        settings.isSetFpTime = true;
                                    }
                                    li = value.id + 1;
                                    settings.lb++;
                                });

                                if (li) {
                                    settings.lastImg = li;
                                    $('#picNum').html(li);
                                }
                                if ($('#autoRunPic').prop('checked')) {
                                    var sTop = $('#makedImg')[0].scrollHeight;
                                    $('#makedImg').scrollTop(sTop);
                                }

                            } else {
                                //请求无数据的次数
                                if (settings.noneDataNum > 5) {
                                    console.log('请求错误超过5次');
                                } else {
                                    settings.noneDataNum++
                                }
                            }
                        },
                        dataType: 'json',
                        error: function () {
                            settings.isOver = 1;
                            //alert('图片请求错误,再次尝试请求中!');
                            VOD.Plugin.tips("error", '图片请求错误,再次尝试请求中!');
                        }
                    });
                } else {
                    console.log("null taskid")
                }
            }
            var getSty2 = function () {
                if (settings.taskid && settings.isStart) {

                    $.get(dotData.sty2Url , {
                        'key': settings.taskid,
                        'index': 0,
                        'offset': 100,
                        'from_client': true
                    }, function (data) {
                        //adLibList = [];
                        global.  sty2Data = data;
                        var ad_lib_list = data.list.splice(settings.last_i);
                        $.each(ad_lib_list, function (i, item) {
                            if (item.video_list[item.video_list.length - 1] > parseInt($("#picNum").text(), 10) - 1 || item.video_list.length === 0) {
                                return;
                            }
                            settings.last_i++;

                            var drawUnderline = function (id, color) {
                                try {
                                    var html = '<div style="left:50%;position:absolute;width:50%;height:3px;border-bottom:3px solid ' + color + ';"></div>';
                                    $('#cate-' + id).append(html);
                                }
                                catch (e) {
                                    console.log(e.message);
                                }
                            }

                            if (item.type == global.adLibHead || item.type ==  global.adLibTail) {
                                $.each(item.video_list, function (j, id) {
                                    if ($('#cate-' + id).attr("style") != undefined)
                                        drawUnderline(id, 'green');
                                    else
                                        $('#cate-' + id).css('border-bottom', '3px solid green');
                                });
                            }
                            else if (item.type == VOD.CONFIG("adLib")) {
                                if (item.video_list.length > 0){
                                    settings.adLibList.push({s: item.video_list[0], e: item.video_list[item.video_list.length - 1]});
                                    }

                            //    var i = 0;
                            //    var la = item.video_list.length;
                                $.each(item.video_list, function (j, id) {
                                    if ($('#cate-' + id).attr("style") != undefined)
                                        drawUnderline(id, 'red');
                                    else {
                                        $('#cate-' + id).css('border-bottom', '3px solid red');
                                    }
                                   // i++;
                                });
                            }
                        });
                    }, 'json');
                }
            }

            function getOcr() {
                g_mutex = 1;
                var tmp = [];
                if (settings.taskid && settings.isStart) {
                    $.get(dotData.ocrUrl, {
                        'key' : settings.taskid,
                        'index' : 0,
                        'type' : 1,
                        'from_client' : true
                    }, function (data) {

                       var ocr_list = data.list;
                        var len = ocr_list.length;
                    //   var g_ocrIndex = len;
                        if (len) {
                            for (var i in ocr_list) {
                                if (ocr_list[i]['text'] == '' || ocr_list[i]['text'].length == 1 || ocr_list[i]['video_list'] == '')
                                    continue;

                                for (var j in ocr_list[i]['video_list']) {
                                    ocr_list[i]['video_list'][j] = ocr_list[i]['video_list'][j] - 1;
                                }

                                var tmp2 = [];

                                if (ocr_list[i]['video_list'].length == 1) {
                                    tmp2['first'] = tmp2['last'] = ocr_list[i]['video_list'].shift();
                                } else {
                                    tmp2['first'] = ocr_list[i]['video_list'].shift();
                                    tmp2['last'] = ocr_list[i]['video_list'].pop();

                                }
                                tmp2['title'] = ocr_list[i]['text'];
                                tmp.push(tmp2);
                            }
                        }

                        if (tmp != '') {
                            if ($("#ocr").hasClass("disabled")) {
                                $("#ocr").removeClass("disabled");
                            }

                            g_ocrList = tmp;
                        }
                        g_mutex = 0;
                    }, 'json')
                }
            }
            function getAcr() {
                g_aMutex = 1;
                var tmp = [];
                if (settings.taskid && settings.isStart) {
                    $.get(dotData.acrUrl, {
                        'key' : settings.taskid,
                        'index' : 0,
                        'type' : 1,
                        'from_client' : true
                    }, function (data) {

                       var acr_list = data.list;
                        var len = acr_list.length;
                        var g_acrIndex = len;
                        if (len) {
                            for (var i in acr_list) {
                                if (acr_list[i]['text'] == '' || acr_list[i]['video_list'] == '')
                                    continue;

                                for (var j in acr_list[i]['video_list']) {
                                    acr_list[i]['video_list'][j] = acr_list[i]['video_list'][j] - 1;
                                }

                                var tmp2 = [];

                                if (acr_list[i]['video_list'].length == 1) {
                                    tmp2['first'] = tmp2['last'] = acr_list[i]['video_list'].shift();
                                } else {
                                    tmp2['first'] = acr_list[i]['video_list'].shift();
                                    tmp2['last'] = acr_list[i]['video_list'].pop();

                                }
                                tmp2['title'] = acr_list[i]['text'];
                                tmp.push(tmp2);
                            }
                        }

                        if (tmp != '') {
                            if ($("#acr").hasClass("disabled")) {
                                $("#acr").removeClass("disabled");
                            }

                            g_acrList = tmp;
                        }
                        g_aMutex = 0;
                    }, 'json')
                }
            }
            return {
                getData: getData,
                getSty2:getSty2,
                getOcr:getOcr,
                getAcr:getAcr
            }
        })()
    }
);
/**
 * Created by karkarrotxu on 2017/01/19.
 */
define(
    '../specimenCollection/Specimen',['require','exports','module'],function (require, exports, module) {
        window.Specimen = window.Specimen || {
            version: '1.0'
        };
        //http://10.1.22.212:8282/add?album_id=xxx&qipu_id=xxx&news_name=xxx&album_name=xxx&channel=xxx&start_time=xxx&end_time=xxx
        //http://10.1.22.212:8282/modify?qipu_id=xxx&news_name=xxx
        //http://10.1.22.212:8282/delete?album_id=xxx&qipu_id=xxx
        //http://10.1.22.212:8282/query?start=0&end=39
        //http://10.1.22.212:8282/query_shot?album_id=xxx&start=0&end=99
        //http://10.1.22.212:8282/update_shot?album_id=xxx&pic_name=name1,name2,name3...
        //http://10.1.22.212:8282/query_ocr_loc?album_id=xxx&start=0&end=99
        //http://10.1.22.212:8282/down_shot?album_id=xxx&qipu_id=xxx
        //http://10.1.22.212:8282/down_topic?album_id=xxx&qipu_id=xxx
        Specimen.Constant = {
            baseApiUrl: "/api/",
            test_api_base_url: "http://10.110.48.80:8282/",
            online_api_base_url: "http://10.77.47.63:8282/",
          //  online_api_base_url: "http://shotocrdump.qiyi.domain:8282/",
            online_source_query_url: "http://mams2.qiyi.domain/",
            test_source_query_url: "http://10.15.187.90/",
            devMode: auth.dev()
        }
//http://10.15.187.90/mams-web/services/program/getProductVideoByAlbumId.action?albumId=200005923&globalPublishDateStart=20170227&globalPublishDateEnd=20170301
        //http://mams2.qiyi.domain/mams-web/services/program/getProductVideoByAlbumId.action?albumId=200005553&globalPublishDateStart=20160406&globalPublishDateEnd=20160408
//mams-web/services/program/getProductVideoByAlbumId.action
        Specimen.urlConfig = (function () {
            var useUrl = Specimen.Constant.baseApiUrl;
            var serverUrl = auth.dev() ? Specimen.Constant.test_api_base_url : Specimen.Constant.online_api_base_url;
            var source_query_url = ( auth.dev() ? Specimen.Constant.test_source_query_url : Specimen.Constant.online_source_query_url ) + "mams-web/services/program/getProductVideoByAlbumId.action";
            var getSpecimenListUrl = serverUrl + "query";
            var addSpecimenUrl = serverUrl + "add";
            var delSpecimenUrl = serverUrl + "delete"
            var modifySpecimenUrl = serverUrl + "modify";
            var downloadShotUrl = serverUrl + "down_shot";
            var downloadTopicUrl = serverUrl + "down_topic";
            var queryShotUrl = serverUrl + "query_shot";
            var updateShotUrl = serverUrl + "update_shot";
            var downShotUrl = serverUrl + "down_shot";
            var downTopicUrl = serverUrl + "down_topic";
            return {
                getSpecimenListUrl: getSpecimenListUrl,
                delSpecimenUrl: delSpecimenUrl,
                addSpecimenUrl: addSpecimenUrl,
                modifySpecimenUrl: modifySpecimenUrl,
                downloadShotUrl: downloadShotUrl,
                downloadTopicUrl: downloadTopicUrl,
                queryShotUrl: queryShotUrl,
                updateShotUrl: updateShotUrl,
                downShotUrl: downShotUrl,
                downTopicUrl: downTopicUrl,
                source_query_url: source_query_url
            }
        })()
    }
);
define(
    '../specimenCollection/Specimen.Action',['require','exports','module'],function (require, exports, module) {
        Specimen.Action = (function () {
            var editForm = null;
            var listGrid = null;
            var hostGrid = null;
            var getListGrid = function (options) {
                if (!listGrid) {
                    listGrid = new Specimen.Grid($.extend(true, {
                        $grid:$("#list"),
                        $downloadGrid:$("#downloadList"),
                        type: 0
                    }, options));
                }
                return listGrid;
            }

            function  editRun () {
                if(editForm == null){
                    editForm = new Specimen.Edit($.extend(true, {
                    }, {}));
                    editForm.init();
                }
                console.log(' editRun ');
            }
            function listRun(options){
                listGrid = getListGrid(options);
                listGrid.runList();
                console.log('list grid run');
            }

            function hostFrameRun(){
                if(!hostGrid){
                    hostGrid = new Specimen.Grid($.extend(true, {
                        type: 0
                    }, {}));
                }
                hostGrid.hostRun();
            }

            return {
                listRun:listRun,
                editRun:editRun,
                hostFrameRun:hostFrameRun
            }
        })();
    }
);
///import js-src/lib/
///import js-src/com/
define('../specimenCollection/Specimen.Config',['require','exports','module'],function (require, exports, module) {
    Specimen.Config = $.extend({}, {}, {
        TABLE_COLMODEL_CONFIG: {
            album_id: {
                name: "album_id",
                index: 'album_id',
                title: false,
                width: 120,
                align: "center",
                sortable: false
            },
            qipu_id: {
                name: "qipu_id",
                index: 'qipu_id',
                title: false,
                width: 120,
                align: "center",
                sortable: false
            },
            news_name: {
                name: "news_name",
                index: 'news_name',
                title: false,
                width: 120,
                align: "center",
                sortable: false
            },
            album_name: {
                name: "album_name",
                index: 'album_name',
                title: false,
                width: 120,
                align: "center",
                sortable: false
            },
            channel: {
                name: "channel",
                index: 'channel',
                title: false,
                width: 120,
                align: "center",
                sortable: false
            },
            status: {
                name: "status",
                index: 'status',
                title: false,
                width: 120,
                align: "center",
                sortable: false,
                formatter: function (v, o, r) {
                    return Specimen.Util.formatter.status(v, o, r);
                }
            },
            host_sample: {
                name: "host_sample",
                index: 'host_sample',
                title: false,
                width: 120,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Specimen.Util.formatter.specimen_status(v, o, r);
                }
            },
            topic_sample: {
                name: "topic_sample",
                index: 'topic_sample',
                title: false,
                width: 120,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Specimen.Util.formatter.specimen_status(v, o, r);
                }
            },
            specimen_operate: {
                title: false,
                sortable: false,
                width: 220,
                align: "center",
                formatter: function (v, o, r) {
                    return Specimen.Util.formatter.specimen_operate(v, o, r);
                }
            },
            date_range: {
                name: "date_range",
                index: 'date_range',
                title: false,
                width: 130,
                align: "center",
                sortable: false,
                formatter: function (v, o, r) {
                    return Specimen.Util.formatter.date_range(v, o, r);
                }
            },
            specimen_download: {
                title: false,
                sortable: false,
                width: 120,
                align: "center",
                formatter: function (v, o, r) {
                    return Specimen.Util.formatter.specimen_download(v, o, r);
                }
            },
            //   colModel: ["rar_name", "download_url"],
            rar_name:{
                name:"name",
                title: false,
                sortable: false,
                width: 120
            },
            download_url: {
                name: "down_path",
                title: false,
                sortable: false,
                width: 120,
                formatter: function (v, o, r) {
                    return Specimen.Util.formatter.download_url(v, o, r);
                }
            }
        },
        TABLE_LIST: {
            beforeProcessing: function (data, status, xhr) {
                var self = this;
                var listData = data.data;
                listData.total =  parseInt( listData.total);
                listData.pageSize =  parseInt( listData.pageSize);
                listData.pageNo = parseInt( listData.pageNo);
                var rest =  listData.total % listData.pageSize;
                listData.totalPages = (listData.total - rest ) / listData.pageSize + (rest == 0 ? 0 : 1);
                listData.result =  listData.result == null ? [] : listData.result;
                var fillData = {"total": listData.totalPages, "page": listData.pageNo , "records": listData.total, "rows": listData.result};
                //{"total": total, "page": cur, "records": dataLength, "rows": showData}
                Specimen.Config.PageBeanSpecimen.setNewData(fillData.rows ,40);
                $("#list")[0].addJSONData(fillData);
                Specimen.Util.showNoResult(fillData.rows.length, "#list");
                return false;
            },
            jsonReader: {
                id: "album_id",
                root: "rows",
                page: "page",
                total: "total",
                records: "records"
            },
            mtype: "get",
            multiselect: false,
            datatype: "local",
            height: 450,
            rowNum: 40,
            caption: "新闻样本采集列表",
            colNames: ["专辑ID", "奇谱ID", "新闻名称", "专辑名称", "频道", "时间范围", "抽帧状态", "主持人帧采样状态", "新闻标题采样状态", "操作", "样本下载" ],
            colModel: ["album_id", "qipu_id", "news_name", "album_name", "channel", "date_range", "status", "host_sample", "topic_sample", "specimen_operate", "specimen_download" ],
            pager: "#pager",
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            }
        },
        TABLE_DOWNLOAD_LIST:{
            mtype: "get",
            multiselect: false,
            datatype: "local",
            colNames: ["压缩包名称", "样本下载"],
            colModel: ["rar_name", "download_url"],
            pager: "#dowloadpage",
            height: 350,
            width:600,
            rowNum: 40,
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            onPaging: function (pgButton) {
                var retValue = Specimen.Util.pageBeanPageHandler("downloadList", "dowloadpage", Specimen.Config.PageBeanDownload, pgButton);
                if (retValue != null) {
                    $("#downloadList")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },

        PageBeanSpecimen: null,
        PageBeanDownload:null,
        queryComponent: null,
        mock_mode: false,
        IS_ADD: false,
        IS_MODIFY: false,

        HOST_TEMPLATE: '<div class="f-left" id="cate-@pid"><img class="fragment-img" id="img-@pid" src="@src" ><br><span class="pid">@pid</span></div>',
        HOST_SIGN: '<div class="host_sign" ><label>主持人</label></div>',
        TABLE_TITLE:["主持人帧采样下载","新闻标题采样下载"],
        HINT_MSG:{
            AUTH_FORBIDDEN:"很抱歉，您没有权限!",
            ATUH_FORBIDDEN_DEL:"很抱歉，您没有删除权限!",
            CODE_SUC:"A00000"
        }
    })
})
//
;
define(
    '../specimenCollection/Specimen.Dao',['require','exports','module'],function (require, exports, module) {
        Specimen.Dao = $.extend({}, EpgWeb.Dao, {
            cache: {},
            getDataByTargetName: function (targetName) {
                if (!this.cache.hasOwnProperty(targetName)) {
                    if (this.hasOwnProperty("method_" + targetName)) {
                        var target = this["method_" + targetName]();
                        this.cache[targetName] = target;
                        return target;
                    } else {
                        return null;
                    }
                } else {
                    return this.cache[targetName];
                }
            },
            method_host_list: function () {
                var obj = {
                    start: 0,
                    end: 99,
                    pic_total: 0,
                    pic_update: 0,
                    marked_current: 0,
                    marked_total: 0,
                    current_num: 0
                };
                return obj;
            },

            delSpecimen: function (data, callback) {
                this.doGet(Specimen.urlConfig.delSpecimenUrl, data, callback)
            },
            modifySpecimen: function (data, callback) {
                this.doGet(Specimen.urlConfig.modifySpecimenUrl, data, callback)

            },
            addSpecimen: function (data, callback) {
                this.doGet(Specimen.urlConfig.addSpecimenUrl, data, callback)
            },

            doDownShot: function (data, callback) {
                this.doGet(Specimen.urlConfig.downShotUrl, data, callback)
            },
            doDownTopic: function (data, callback) {
                this.doGet(Specimen.urlConfig.downTopicUrl, data, callback)
            },
            getQueryShot: function (data, callback) {
                this.doGet(Specimen.urlConfig.queryShotUrl, data, callback)
            },
            doUpdateShot: function (data, callback) {
                this.doGet(Specimen.urlConfig.updateShotUrl, data, callback)
            },
            queryAlbumSource: function (data, callback) {
                var options = {
                    url: Specimen.urlConfig.source_query_url,
                    type: "get",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                this.sendProxy(options)
            }
        })
    }
);
define(
    '../specimenCollection/Specimen.Edit',['require','exports','module'],function (require, exports, module) {
        Specimen.Edit = function (options) {
            this.dao = Specimen.Dao;
            this.config = Specimen.Config;
            this.options = options || {};
        };

        Com.inherits(Specimen.Edit, Ancestor.Grid, function (options) {
        }).extend({
            init: function () {
                var self = this;
                self.bindEvent();
                if (Com.url.getParameter("qipu_id") != null) {
                    $("li[name=modifyText]").html("修改");
                    Specimen.Config.IS_MODIFY = true;
                    $("#modifyContainer").show();
                    self.initModifyHandler();
                } else {
                    $("li[name=modifyText]").html("添加");
                    Specimen.Config.IS_ADD = true;
                    $("#addContainer").show();
                    self.initAddHandler();
                }

            },
            initModifyHandler: function () {
                var self = this;
                var parent = $("#modifyContainer");
                var element = Specimen.Util.getAlbumDataByUrl()
                parent.find("span[name=span_album_id]").html(element.album_id);
                parent.find("input[name=input_news_name]").val(element.news_name);
                parent.find("span[name=span_startTime]").html(element.start_time);
                parent.find("span[name=span_endTime]").html(element.end_time);
                parent.find("span[name=span_qipu_id]").html(element.qipu_id);
                parent.find("span[name=span_album_name]").html(element.album_name);
                parent.find("span[name=span_channel_name]").html(element.channel);

            },
            initAddHandler: function () {
                var self = this;
                $('div[name=multiAddDiv]').addndel({
                    rowClass: 'control-group',
                    insertOrder:"after",
                    addDecorator: function ($newRow, $clickedRow) {
                        if ($(".my-border").length == 10) {
                            SystemDialog.queryAlert("最多同时编辑10个！");
                            return false;
                        }
                        $newRow.find("input[name=input_startTime]").datepicker({dateFormat: "yymmdd"});
                        $newRow.find("input[name=input_endTime]").datepicker({dateFormat: "yymmdd"});
                        return true;
                    }
                })

                $("input[name=input_startTime]").datepicker({dateFormat: "yymmdd"});
                $("input[name=input_endTime]").datepicker({dateFormat: "yymmdd"});
            },
            bindEvent: function () {
                $("button[name=btn_submit]").bind("click", function (e) {
                    if (Specimen.Config.IS_MODIFY) {
                        Specimen.Util.submitModifySpecimen();
                    } else if (Specimen.Config.IS_ADD) {
                        Specimen.Util.submitNewSpecimen();
                    }
                })
                $("button[name=btn_goback]").bind("click", function (e) {
                    Specimen.Util.goBackToList("取消");
                })
            }

        })
    }
);
define('../specimenCollection/Specimen.Util',['require','exports','module'],function (require, exports, module) {
    Specimen.Util = $.extend(true, {}, EpgWeb.Util, {
        formatter: {
            specimen_operate: function (v, o, r) {
                var htmlArr = [];
                if (r.status == 1) {
                    htmlArr.push("<a href='javascript:;' data-id='@id' onclick='Specimen.Util.jumpToHostSpecimen(this)'>主持人帧采样</a>")
                    htmlArr.push("<a href='javascript:;' data-id='@id' onclick='Specimen.Util.jumpToNewsSpecimen(this)'>新闻标题采样</a>")
                } else {
                    htmlArr.push("<a class='disabled'>主持人帧采样</a>");
                    htmlArr.push("<a class='disabled'>新闻标题采样</a>");
                }

                htmlArr.push("<a href='javascript:;' data-id='@id' onclick='Specimen.Util.modifySpecimen(this)'>修改</a>")
                htmlArr.push("<a href='javascript:;' data-id='@id' onclick='Specimen.Util.delSpecimen(this)'>删除</a>")
                return htmlArr.join(" ").replace(/@id/g, r.qipu_id + "");
            },
            specimen_status: function (v, o, r) {
                return "已标注N个样本".replace("N", "" + v);
            },
            status: function (v, o, r) {
                var ret = "";
                v = parseInt(v);
                switch (v) {
                    case 0:
                        ret = "抽帧中";
                        break;
                    case 1:
                        ret = "已完成";
                        break;
                    case 2:
                        ret = "抽帧失败";
                        break;
                    default:
                        ret = "未知状态：" + v;
                        break;
                }
                return ret;
            },
            date_range: function (v, o, r) {
                return  r.start_time + "-" + r.end_time;
            },
            specimen_download: function (v, o, r) {
                var htmlArr = [];
                htmlArr.push("<a href='javascript:;' data-id='@id' onclick='Specimen.Util.downloadHost(this)'>主持人帧</a>")
                htmlArr.push("<a href='javascript:;' data-id='@id' onclick='Specimen.Util.downloadNews(this)'>新闻标题</a>")
                return htmlArr.join(" ").replace(/@id/g, r.qipu_id + "");
            },
            download_url: function (v, o, r) {
                return "<a download='" + r.name + "' href='" + v + "'>样本下载</a>";
            }
        },
        downloadHost: function (element) {
            var elementData = Specimen.Config.PageBeanSpecimen.findData("qipu_id", $(element).attr("data-id"));
            var params = {
                qipu_id: elementData.qipu_id,
                album_id: elementData.album_id
            };
            Specimen.Dao.doDownShot(params, function (data) {
                if (data == null) {
                    EpgWeb.Plugin.showTips({content: "下载（主持人帧）接口 异常", type: "error"})
                } else if (data.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                    Specimen.Config.PageBeanDownload.setNewData(data.data.result);
                    Specimen.Util.openDownloadView(elementData.news_name, 0);
                } else {
                    EpgWeb.Plugin.showTips({content: data.msg, type: "error"})
                }
            })
        },

        downloadNews: function (element) {
            var elementData = Specimen.Config.PageBeanSpecimen.findData("qipu_id", $(element).attr("data-id"));
            var params = {
                qipu_id: elementData.qipu_id,
                album_id: elementData.album_id
            };
            Specimen.Dao.doDownTopic(params, function (data) {
                if (data == null) {
                    EpgWeb.Plugin.showTips({content: "下载（新闻标题）接口 异常", type: "error"})
                } else if (data.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                    Specimen.Config.PageBeanDownload.setNewData(data.data.result);
                    Specimen.Util.openDownloadView(elementData.news_name, 1);
                } else {
                    EpgWeb.Plugin.showTips({content: data.msg, type: "error"})
                }
            })
        },
        openDownloadView: function (news_name, table_mode) {
            $('#downloadDiv').dialog("option", "title", "新闻名称：" + news_name);
            $('#downloadDiv').dialog("open");
            var table_title = Specimen.Config.TABLE_TITLE[table_mode];
            $("#downloadList").setCaption(table_title);
            $("#downloadList")[0].addJSONData(Specimen.Config.PageBeanDownload.getCur());
        },
        jumpToHostSpecimen: function (element) {
            Specimen.Dao.doAuthData({
                url: '/epg/auth/specimen_senior',
                doError: function () {
                    EpgWeb.Plugin.showTips({content: Specimen.Config.HINT_MSG.AUTH_FORBIDDEN, type: "error"})
                },
                doSuccess: function () {
                    var elementData = Specimen.Config.PageBeanSpecimen.findData("qipu_id", $(element).attr("data-id"));
                    var params = {
                        qipu_id: elementData.qipu_id,
                        album_id: elementData.album_id,
                        news_name: encodeURIComponent(elementData.news_name),
                        album_name: encodeURIComponent(elementData.album_name),
                        channel: encodeURIComponent(elementData.channel)
                    };
                    var openUrl = "specimen_host_frame.html?" + Specimen.Util.transGetParams(params)
                    window.open(openUrl);
                }
            })
        },
        jumpToNewsSpecimen: function (element) {

            Specimen.Dao.doAuthData({
                url: '/epg/auth/specimen_senior',
                doError: function () {
                    EpgWeb.Plugin.showTips({content: Specimen.Config.HINT_MSG.AUTH_FORBIDDEN, type: "error"})
                },
                doSuccess: function () {
                    var elementData = Specimen.Config.PageBeanSpecimen.findData("qipu_id", $(element).attr("data-id"));
                    var params = {
                        qipu_id: elementData.qipu_id,
                        album_id: elementData.album_id,
                        news_name: encodeURIComponent(elementData.news_name),
                        album_name: encodeURIComponent(elementData.album_name),
                        channel: encodeURIComponent(elementData.channel)
                    };
                    var openUrl = "specimen_news_title.html?" + Specimen.Util.transGetParams(params)
                    window.open(openUrl);
                }
            })
        },
        addSpecimen: function () {
            Specimen.Dao.doAuthData({
                url: '/epg/auth/specimen_senior',
                doError: function () {
                    EpgWeb.Plugin.showTips({content: Specimen.Config.HINT_MSG.AUTH_FORBIDDEN, type: "error"})
                },
                doSuccess: function () {
                    var openUrl = "specimen_edit.html";
                    window.open(openUrl);
                }
            })
        },
        modifySpecimen: function (element) {
            Specimen.Dao.doAuthData({
                url: '/epg/auth/specimen_senior',
                doError: function () {
                    EpgWeb.Plugin.showTips({content: Specimen.Config.HINT_MSG.AUTH_FORBIDDEN, type: "error"})
                },
                doSuccess: function () {
                    var elementData = Specimen.Config.PageBeanSpecimen.findData("qipu_id", $(element).attr("data-id"));
                    var params = {
                        qipu_id: elementData.qipu_id,
                        album_id: elementData.album_id,
                        news_name: encodeURIComponent(elementData.news_name),
                        album_name: encodeURIComponent(elementData.album_name),
                        channel: encodeURIComponent(elementData.channel),
                        start_time: elementData.start_time,
                        end_time: elementData.end_time
                    };

                    var openUrl = "specimen_edit.html?" + Specimen.Util.transGetParams(params);
                    window.open(openUrl, "_blank");
                }
            })
        },
        goBackToList: function (keyMsg) {
            SystemDialog.queryConfirm("确认要" + keyMsg + "么？", function (flag) {
                if (flag) {
                    var openUrl = "specimen_list.html";
                    window.open(openUrl);
                }
            });
        },
        delSpecimen: function (element) {
            Specimen.Dao.doAuthData({
                url: '/epg/auth/specimen_senior',
                doError: function () {
                    EpgWeb.Plugin.showTips({content: Specimen.Config.HINT_MSG.ATUH_FORBIDDEN_DEL, type: "error"})
                },
                doSuccess: function () {
                    var id = $(element).attr("data-id")
                    var data = Specimen.Config.PageBeanSpecimen.findData("qipu_id", id)
                    var $data = {qipu_id: data.qipu_id, album_id: data.album_id};
                    SystemDialog.queryConfirm("确认要删除么？", function (flag) {
                        if (flag) {
                            Specimen.Dao.delSpecimen($data, function (data) {
                                if (data == null) {
                                    EpgWeb.Plugin.showTips({type: "error", content: "Specimen delSpecimen has error" })
                                } else if (data.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                                    EpgWeb.Plugin.showTips({content: "删除成功" });
                                    $("#list").trigger("reloadGrid");
                                } else {
                                    EpgWeb.Plugin.showTips({type: "error", content: data.msg })
                                }
                            })
                        }
                    })
                }
            })
        },
        fillAlbumData: function (element) {
            console.log("fillAlbumData" + element.value);
            var albumId = $(element).val();
            if (albumId.length == 0) {
                return;
            }
            if (!EpgWeb.Plugin.Validate.baseCheck({value: albumId, error: "专辑id格式错误", type: "positive"})) {
                return;
            }
            var parentDiv = $(element).parent().parent();
            Specimen.Util.cleanSpecimenCell(parentDiv);
            var options = {
                url: EpgWeb.Constant.thirdUrl_apis_search_area_url,
                data: {t: 1, filter_EQL_entityId: albumId},
                type: "get",
                success: function (data) {
                    console.log(" 加载专辑数据[" + albumId + "]结束");
                    if (data == null) {
                        EpgWeb.Plugin.showTips({type: "加载专辑数据[" + albumId + "] 接口异常", content: data.msg});
                    } else if (data.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                        if (data.data.result.length > 0) {
                            var queryData = data.data.result[0];
                            Specimen.Util.fillSpecimenCell(parentDiv, queryData);
                        } else {
                            EpgWeb.Plugin.showTips({type: "error", content: "不存在专辑id:" + albumId});
                        }
                    } else {
                        EpgWeb.Plugin.showTips({type: "error", content: data.msg});
                    }
                },
                error: function (data) {
                    console.log(" 加载专辑数据[" + albumId + "]失败");
                }
            }
            Specimen.Dao.sendProxy(options);
        },
        cleanSpecimenCell: function ($parent) {
            $parent.find("span[name=span_qipu_id]").html("");
            $parent.find("span[name=span_album_name]").html("");
            $parent.find("span[name=span_channel_name]").html("");
            $parent.attr("has-submit", false);
            $parent.find("span[name=hint_info]").parent().hide();
        },
        fillSpecimenCell: function ($parent, queryData) {
            $parent.attr("submit-dataid", queryData.qipuId);
            $parent.find("span[name=span_qipu_id]").html(queryData.qipuId);
            $parent.find("span[name=span_album_name]").html(queryData.displayName);
            $parent.find("span[name=span_channel_name]").html(queryData.channelName);
        },
        doErrorSpecimenCell: function (qipuId, msg, index) {
            var parent = $("div[submit-dataid=" + qipuId + "]")
            var infoSpanArr = parent.find("span[name=hint_info]");
            if (index == null) {
                index = 0;
            }
            var infoSpan = $(infoSpanArr[index]);
            infoSpan.removeClass("hint-info-red").removeClass("hint-info-green");
            infoSpan.addClass("hint-info-red");
            infoSpan.html(msg);
            infoSpan.parent().show();
        },
        doSucSpecimenCell: function (qipuId, msg) {
            var parent = $("div[submit-dataid=" + qipuId + "]");
            var infoSpan = parent.find("span[name=hint_info]");
            infoSpan.removeClass("hint-info-red").removeClass("hint-info-green");
            parent.attr("has-submit", true);
            infoSpan.addClass("hint-info-green");
            infoSpan.html(msg);
            infoSpan.parent().show();
        },
        //pic_addr_0
        fillImageZone: function (dataArr) {
            var htmlArr = [];
            var j = 0;
            $.each(dataArr, function (i, element) {
                j++;
                element.imgId = j;
                element.pid = j;
                element.src = Specimen.Util.makeUpHostImgUrl(element);
                htmlArr.push(Specimen.Util.replaceHostTpl(element));
            })
            Specimen.Config.PageBeanSpecimen.setNewData(dataArr);
            return htmlArr.join("");
        },
        makeUpHostImgUrl: function (element) {
            return element.pic_path + "/" + element.pic_addr + ".jpg"
        },

        replaceHostTpl: function (element) {
            return Specimen.Config.HOST_TEMPLATE.replace(/@src/, element.src).replace(/@pid/g, element.pid)
        },

        imgloadComplete: function (element) {
            console.log(element.width, element.height);
        },
        submitNewSpecimen: function () {
            var dataArr = $(".my-border");
            var newArr = [];
            var validArr = [];
            $.each(dataArr, function (i, element) {
                var targetDiv = $(element);
                var submitData = {album_id: null, qipu_id: null, news_name: null, album_name: null, channel: null, start_time: null, end_time: null};
                if ("true" != targetDiv.attr("has-submit")) {
                    submitData.album_id = targetDiv.find("input[name=input_album_id]").val();
                    submitData.news_name = targetDiv.find("input[name=input_news_name]").val().trim();
                    submitData.start_time = targetDiv.find("input[name=input_startTime]").val();
                    submitData.end_time = targetDiv.find("input[name=input_endTime]").val();
                    submitData.album_name = targetDiv.find("span[name=span_album_name]").html();
                    submitData.qipu_id = targetDiv.find("span[name=span_qipu_id]").html();
                    submitData.channel = targetDiv.find("span[name=span_channel_name]").html();
                    if (!submitData.album_id || !submitData.album_name || !submitData.qipu_id || !submitData.channel || !submitData.news_name || !submitData.start_time || !submitData.end_time) {
                        submitData.msgData = {type: "error", msg: "参数不完整", index: 0}
                    } else if (submitData.start_time > submitData.end_time) {
                        submitData.msgData = {type: "error", msg: "时间范围格式错误", index: 0}
                    }
                    submitData.news_name = encodeURIComponent(submitData.news_name);
                    submitData.album_name = encodeURIComponent(submitData.album_name);
                    submitData.channel = encodeURIComponent(submitData.channel);
                    newArr.push(submitData);
                }
            })

            if (newArr.length > 0) {
                var map = {};
                $.each(newArr, function (i, element) {
                    if (!map.hasOwnProperty("" + element.qipu_id)) {
                        map["" + element.qipu_id] = [];
                    }
                    map["" + element.qipu_id].push(element);
                    if (map["" + element.qipu_id].length > 1) {
                        element.msgData = {type: "error", msg: "数据重复", index: map["" + element.qipu_id].length - 1}
                    }
                    if (element.msgData == null) {
                        validArr.push(element)
                    } else {
                        Specimen.Util.doErrorSpecimenCell(element.qipu_id, element.msgData.msg, element.msgData.index);
                    }
                })
            }
            if (validArr.length > 0) {
                if (Specimen.Config.queryComponent == null) {
                    Specimen.Config.queryComponent = Specimen.Util.getQueryComponent({
                        doBefore: function () {
                            Specimen.Util.disableEditSubmit();
                        },
                        doAfter: function () {
                            Specimen.Util.enableEditSubmit();
                        },
                        doSingle: function (element, notifyHandler) {
                            var queryElement = {albumId: element.album_id, globalPublishDateStart: element.start_time, globalPublishDateEnd: element.end_time};
                            Specimen.Dao.queryAlbumSource(queryElement, function (sourceData) {
                                if (sourceData == null) {
                                    Specimen.Util.doErrorSpecimenCell(element.qipu_id, "无法获取专辑成片，请联系lego人员!");
                                    notifyHandler()
                                } else if (sourceData.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                                    if (sourceData.data == null || sourceData.data.length == 0) {
                                        Specimen.Util.doErrorSpecimenCell(element.qipu_id, "没有专辑成片数据，请联系lego人员!");
                                        notifyHandler();
                                    } else {
                                        Specimen.Dao.addSpecimen(element, function (data) {
                                            console.log(element.qipu_id);
                                            if (data == null) {
                                                Specimen.Util.doErrorSpecimenCell(element.qipu_id, "请求异常");
                                            } else if (data.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                                                Specimen.Util.doSucSpecimenCell(element.qipu_id, "提交成功")
                                            } else {
                                                Specimen.Util.doErrorSpecimenCell(element.qipu_id, data.msg);
                                            }
                                            notifyHandler()
                                        })
                                    }
                                } else {
                                    Specimen.Util.doErrorSpecimenCell(element.qipu_id, "获取专辑成片失败，请联系lego人员!错误：" + sourceData.msg);
                                    notifyHandler()
                                }
                            })
                        }
                    });
                }
                Specimen.Config.queryComponent.doInit(validArr);
            }
        },

        submitModifySpecimen: function () {
            var targetDiv = $("#modifyContainer");
            var submitData = {album_id: null, qipu_id: null, news_name: null}
            submitData.album_id = targetDiv.find("span[name=span_album_id]").html();
            submitData.qipu_id = targetDiv.find("span[name=span_qipu_id]").html();
            submitData.news_name = targetDiv.find("input[name=input_news_name]").val().trim();
            if (!submitData.news_name) {
                SystemDialog.queryAlert("新闻标题不能为空!")
                return;
            }
            submitData.news_name = encodeURIComponent(submitData.news_name)
            Specimen.Util.disableEditSubmit();
            Specimen.Dao.modifySpecimen(submitData, function (data) {
                if (data == null) {
                    EpgWeb.Plugin.showTips({type: "error", content: " modifySpecimen 请求发生异常 "});
                } else if (data.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                    EpgWeb.Plugin.showTips({ content: "修改成功"});
                } else {
                    EpgWeb.Plugin.showTips({type: "error", content: " modifySpecimen 请求失败: " + data.msg});
                }

                Specimen.Util.enableEditSubmit();
            })
        },
        disableEditSubmit: function () {
            $("button[name=btn_submit]").prop("disabled", "disabled");
        },
        enableEditSubmit: function () {
            $("button[name=btn_submit]").removeAttr("disabled");
        },
        showNoResult: function (dataLength, tableName) {
            if (tableName == null) {
                tableName = "#list"
            }
            var jqGridTarget = $(tableName);
            var parentElement = jqGridTarget.parent();
            if (parentElement.find(".norecords").html() == null) {
                parentElement.append('<div class="norecords">没有符合数据</div>');
                parentElement.find(".norecords").hide();
            }
            if (dataLength == 0) {
                parentElement.find(".norecords").show();
            } else {
                parentElement.find(".norecords").hide();
            }
        },
        getAlbumDataByUrl: function () {
            var element = {
                qipu_id: Com.url.getParameter("qipu_id"),
                album_id: Com.url.getParameter("album_id"),
                album_name: decodeURIComponent(Com.url.getParameter("album_name")),
                channel: decodeURIComponent(Com.url.getParameter("channel")),
                news_name: decodeURIComponent(Com.url.getParameter("news_name")).trim(),
                start_time: Com.url.getParameter("start_time"),
                end_time: Com.url.getParameter("end_time")
            };
            return element;
        },
        doQueryShot: function () {
            var parent = $("#sportContainer");
            var hostData = Specimen.Dao.getDataByTargetName("host_list");
            var params = { album_id: parent.find("span[name=album_id]").html(), qipu_id: parent.find("span[name=qipu_id]").html(), start: hostData.start, end: hostData.end };
            Specimen.Dao.getQueryShot(params, function (data) {
                if (data == null) {
                    EpgWeb.Plugin.showTips({content: '主持人帧采样图片列表 请求异常 ', type: "error"})
                } else if (Specimen.Config.HINT_MSG.CODE_SUC == data.code) {
                    var hostData = Specimen.Dao.getDataByTargetName("host_list")
                    hostData.pic_total = data.data.total;
                    hostData.pic_update = data.data.update;
                    hostData.start += hostData.pic_update;
                    hostData.end += hostData.pic_update;
                    hostData.marked_total = data.data.label;
                    if(  data.data.result == null ){
                        data.data.result = [];
                    }
                    hostData.current_num =  data.data.result.length;
                    Specimen.Util.updateHostFrame();
                    $("#imageZone").html(Specimen.Util.fillImageZone(data.data.result));
                    $("#imageZone").scrollTop(0);
                } else {
                    EpgWeb.Plugin.showTips({content: '主持人帧采样图片列表 请求失败!' + data.msg, type: "error"})
                }
            });
        },
        submitSelectedHost: function () {
            var pidSpanArr = $("img.select-img").parent().find("span.pid");
            var selectedIdArr = [];
            $.each(pidSpanArr, function (i, element) {
                selectedIdArr.push(parseInt($(element).html()));
            })
            var element = null;
            var selectedIdArrLength = selectedIdArr.length;
            var source = Specimen.Config.PageBeanSpecimen.getSource();
            var unSelected = false;
            var submitArr = [];
            $.each(source, function (i, element) {
                unSelected = true;
                if (selectedIdArrLength > 0) {
                    unSelected = selectedIdArr.indexOf(element.pid) == -1;
                }
                if (!unSelected) {
                    selectedIdArrLength--;
                }
                submitArr.push(element.pic_addr + "_" + (unSelected ? 0 : 1))
            })
            console.log("submitArr  ", JSON.stringify(submitArr));
            var parent = $("#sportContainer");
            var params = {
                album_id: parent.find("span[name=album_id]").html(),
                qipu_id: parent.find("span[name=qipu_id]").html(),
                news_name: parent.find("span[name=news_name]").html(),
                pic_name: submitArr.join(",") };
            Specimen.Util.disableEditSubmit();
            Specimen.Dao.doUpdateShot(params, function (data) {
                if (data == null) {
                    EpgWeb.Plugin.showTips({content: '更新主持人帧采样 请求异常 ', type: "error"})
                } else if (data.code == Specimen.Config.HINT_MSG.CODE_SUC) {
                    var hostData = Specimen.Dao.getDataByTargetName("host_list");
                    hostData.marked_current += selectedIdArr.length;
                    hostData.start += submitArr.length;
                    hostData.end += submitArr.length;
                    Specimen.Util.doQueryShot();
                } else {
                    EpgWeb.Plugin.showTips({content: '更新主持人帧采样 请求失败!' + data.msg, type: "error"})
                }
                Specimen.Util.enableEditSubmit();
            })
        },
        updateHostFrame: function () {
            var hostData = Specimen.Dao.getDataByTargetName("host_list");
            var parent = $("#sportContainer");
            parent.find("span[name=current_marked]").html(hostData.marked_current);
            parent.find("span[name=total_marked]").html(hostData.marked_total);
            parent.find("span[name=current_num]").html(hostData.current_num);
            parent.find("span[name=pic_rest]").html(hostData.pic_total - hostData.start);
        }
    });
});
define(
    '../specimenCollection/Specimen.Grid',['require','exports','module'],function (require, exports, module) {
        Specimen.Grid = function (options) {
            this.dao = Specimen.Dao;
            this.config = Specimen.Config;
            this.options = options || {};
        };
        Com.inherits(Specimen.Grid, Ancestor.Grid).extend({
            // specimen_list.html start
            runList: function () {
                var self = this;
                self.$grid = self.options.$grid;
                self.$downloadGrid = self.options.$downloadGrid;
                self.initListGrid();
                self.initDownloadListGrid();
                self.initDlg();
                self.config.PageBeanSpecimen = Specimen.Util.createPageBean();
                self.config.PageBeanSpecimen.setNewData([], 40);
                self.config.PageBeanDownload = Specimen.Util.createPageBean();
                self.config.PageBeanDownload.setNewData([], 40);
                self.query();
            },

            initListGrid: function (options, callback) {
                var self = this;
                var gridConfig = self.getGridConfig(self.config.TABLE_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.$grid.jqGrid(options);
            },
            initDownloadListGrid: function (options, callback) {
                var self = this;
                var gridConfig = self.getGridConfig(self.config.TABLE_DOWNLOAD_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.$downloadGrid.jqGrid(options);
                $("#dowloadpage_left").css({width: "10px"})
            },
            initDlg: function () {
                $("#downloadDiv").dialog({
                        title: "样本下载",
                        autoOpen: false,
                        width: 700,
                        height: 540,
                        modal: true,
                        dialogClass: 'alert',
                        resizable: false
                    }
                )
                $(".ui-dialog-titlebar-close").html('<span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">close</span>');
            },
            query: function () {
                var self = this;
                self.$grid.setGridParam({page: 1, url: Specimen.urlConfig.getSpecimenListUrl, loadtext: '加载中...',
                    datatype: "json", loadui: "block"}).trigger("reloadGrid");
            },
            // specimen_list.html end
            // specimen_host_frame.html start
            hostRun: function () {
                var self = this;
                self.config.PageBeanSpecimen = new Specimen.Util.createPageBean();
                self.config.PageBeanSpecimen.setNewData([], 40);
                var element = Specimen.Util.getAlbumDataByUrl()
                self.fillHostAlbumData(element);
                self.initHostFrame();
                Specimen.Util.doQueryShot();
            },
            fillHostAlbumData: function (element) {
                var parent = $("#sportContainer");
                parent.find("span[name=news_name]").html(element.news_name);
                parent.find("span[name=album_name]").html(element.album_name);
                parent.find("span[name=album_id]").html(element.album_id);
                parent.find("span[name=qipu_id]").html(element.qipu_id);
                parent.find("span[name=channel_name]").html(element.channel);
            },
            initHostFrame: function () {
                $("#imageZone").on("click", "img", function (e) {
                    var $target = $(e.target);
                    console.log($target.attr("id"));
                    if ($target.hasClass("select-img")) {
                        $target.removeClass("select-img");
                        $target.parent().children().last().remove();
                    } else {
                        $target.addClass("select-img");
                        $target.parent().append($(Specimen.Config.HOST_SIGN));
                    }
                })
                $("button[name=btn_submit]").bind("click", function (e) {
                    if ($("#imageZone img").length == 0) {
                        return;
                    }
                    if ($("img.select-img").length == 0) {
                        SystemDialog.queryConfirm("本次未标注图像,是否确认提交?", function (flag) {
                            if (flag) {
                                Specimen.Util.submitSelectedHost();
                            }
                        })
                    } else {
                        Specimen.Util.submitSelectedHost();
                    }
                })
                $("button[name=btn_goback]").bind("click", function (e) {
                    Specimen.Util.goBackToList("退出");
                })
            }
        })
    }
);
define(
	'../vodad/Vodad',['require','exports','module'],function(require, exports, module){
		window.Vodad = window.Vodad || { version : '1.0' };
		//Video公共配置集合，键值对象
		Vodad.Config = Vodad.Config || {};
		Vodad.Util = Vodad.Util || {};

        Vodad.Constant = {
            devMode: auth.dev()
        }
	}
);
define(
	'../vodad/Vodad.Action',['require','exports','module'],function(require, exports, module){

        Vodad.Action = (function() {
			var vodadGrid = null;
            var getVodadGrid = function(options) {
                if (!vodadGrid) {

                    vodadGrid = new Vodad.Grid($.extend(true, {
                        '$container': $('#VodadListContainer'),
                        type: 0
                    }, options));
                }
                return vodadGrid;
            };
            var vodadGridRun = function(options) {
                vodadGrid = getVodadGrid(options);
                vodadGrid.run();
            };
			var run = function() {
                vodadGridRun({});
            };
            var editBase = null;
            var getEditBase = function(options) {

                if (!editBase) {
                    editBase = new Vodad.Edit(options);
                }
                return editBase;
            };
            var editRun = function() {
                var $container = $('.video-edit-form');
                getEditBase({
                    $container: $container
                }).run();
            };
            return {
                run: run,
				editRun:editRun,
				getVodadGrid:getVodadGrid
            };
        })();
	}
);
define('../vodad/Vodad.Config',['require','exports','module'],function(require, exports, module) {

    Vodad.Config = $.extend({}, Ancestor.Config, {

        VODAD_TYPE: ['视频', '图像'],
        VODAD_CONTENT_TYPE: ['未设置', '压屏条', '压屏角标', '插入型转场', '贴片型转场', '大头贴', '原创贴'],
        UPLOAD_URL: auth.dev() ? "http://10.110.22.78/common_upload" : "http://paopaoupload.iqiyi.com/common_upload",
        UPLOAD_VIDEO_PARAMS: {
            url: "http://fft.qiyi.domain/api/file/",
            access_key: auth.dev() ? "a1339f483f48661" : "4bfc3767d7be0353",
            secret_key: auth.dev() ? "2fd04664202502e9056e77d8504ce43d" : "b257b67be6317733",
            ttl: 86400
        },

        EffectUploadCommonParams: {
            //auth_token: Com.cookie.get('P00001'),
            auth_token: "5aX4BXG5ZM5c8DEwwm1UefCprtQaAwzuwaA0tNAUZFNp6WJDANvSZGq2bd0WZnm1m2m1KA9f",
            qichuan_bizid: "ppc_daobotai",
            file_type: "jpg",
            business_type: "image",
            file_size: "1"
        },

        PageBean: null,

			TABLE_COLMODEL_CONFIG: {
			    'id': {
                    name: 'id',
                    title: false,
                    index: 'id',
                    align:'center',
                    sortable: false,
                    width: 100
                },
				'name': {
					name: 'name',
					title: false,
					index: 'name',
					align:'center',
					sortable: false,
					width: 150
				},
				'type': {
					name: 'type',
					title: false,
					index: 'type',
					align:'center',
					sortable: false,
					width: 150,
					formatter: function(v, o, r) {
                        return Vodad.Util.formatter.type(v,r);
                    }
				},
				'fileSize': {
					name: 'fileSize',
					title: false,
					index: 'fileSize',
					align:'center',
					sortable: false,
					width: 150,
					formatter: function(v, o, r) {
					    return Vodad.Util.formatter.fileSize(v,r);
					}
				},
				'duration': {
				    name: 'duration',
                    title: false,
                    index: 'duration',
                    align:'center',
                    sortable: false,
                    width: 100
				},
				'pic': {
				    name: 'pic',
                    title: false,
                    index: 'pic',
                    align:'center',
                    sortable: false,
                    width: 150,
                    formatter: function(v, o, r) {
                        return Vodad.Util.formatter.img(v,r);
                    }
				},
				'remark': {
				    name: 'remark',
                    title: false,
                    index: 'remark',
                    align:'center',
                    sortable: false,
                    width: 200
				},
				'opUser': {
                    name: 'opUser',
                    title: false,
                    index: 'opUser',
                    align:'center',
                    width: 150,
                    align: 'center',
                },
                'opTime': {
                    name: 'opTime',
                    title: false,
                    index: 'opTime',
                    align:'center',
                    width: 180,
                    align: 'center',
                    formatter: function(v, o, r) {
                        return Vodad.Util.formatter.time(v,r);
                    }
                },
				'operate': {
					name: 'operate',
					title: false,
					index: 'operate',
					width: 140,
					align:'center',
					sortable: false,
					formatter: function(v, o, r) {
						return Vodad.Util.formatter.operate(v,r);
					}
				},
				'contentType': {
                    name: 'contentType',
                    title: false,
                    index: 'contentType',
                    width: 100,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Vodad.Util.formatter.contentType(v,r);
                    }
                },
                'uuid': {
			        name: 'uuid',
                    title: false,
                    index: 'uuid',
                    width: 100,
                    align:'center',
                    sortable: false,
                    hidden: true,
                }
			},

			TABLE: {
			    url: "/api/vod/ad/getList",
			    rowNum: 10,
                pager: "#VodadListPager",
			    multiselect: false,
			    prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

			    loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/vod/ad/getList");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

			    //datatype: "local",
			    loadtext: '加载中...',
                loadui: "block",
                mtype: "post",

				colNames: ["ID", "素材名称", "素材属性", "内容类型", "文件大小(字节|KB|MB)", "时长", "缩略图", "备注", "上传人", "上传时间", "操作", "uuid"],
				colModel: ['id', 'name', 'type', 'contentType', 'fileSize', 'duration', 'pic', 'remark', 'opUser', 'opTime', 'operate', 'uuid']
			}
		});
});
define(
	'../vodad/Vodad.Dao',['require','exports','module'],function(require, exports, module){

        Vodad.Dao = $.extend({}, Ancestor.Dao, {
            getList: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/vod/ad/getList",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/vod/ad/getList");
            },
            add: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/vod/ad/add",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/vod/ad/add");
            },
            delete: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/vod/ad/del",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/vod/ad/del");
            },
            redirect: function(data, callback) {
                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options,'/redirect');
            }

        });
	}
);
define('../vodad/Vodad.Util',['require','exports','module'],function(require, exports, module) {
	Vodad.Util = $.extend(true, {}, EpgWeb.Util, {
			formatter: {
			    type: function (v, r) {
                    return Vodad.Config.VODAD_TYPE[v];
                },
                time: function (v, r) {
                    return v.substring(0, 19);
                },
                img: function (v, r) {
                        return '<img src="' + r.picAddress + '" width="42" height="42">';
                },
                operate:function(v,r) {
                    var str = "<a href='javascript:void(0);' onclick='Vodad.Util.del(" + r.id + ", \"" + r.uuid + "\")' target='_blank'>删除</a>";
                    return str;
                },
                contentType:function(v, r) {
                    return Vodad.Config.VODAD_CONTENT_TYPE[v];
                },
                fileSize: function(v, r) {
                    return v + "|" + (v / 1024).toFixed(2) + "|" + (v / 1024 /1024).toFixed(4);
                }
            },

            del: function(id, uuid){
                var self = this;
                if(window.confirm('是否从素材列表中删除该数据？')) {
                    if (typeof(uuid) != "undefined" && uuid != "") {
                        self.delUploadVideo(uuid);
                    }
                    var params = {id : id};
                    Vodad.Dao.delete(params, function(){
                        $('.query-btn').click();
                    });
                    return true;
                }
            },
            calculateDate: function (str) {//month 7days yestoday today
                var from_date = "", to_date = "";
                var d = new Date();
                var defaultEnd = this.formatDateTimeFormat(d);
                this.setZeroTime(d);
                if (str == "today") {
                    from_date = this.formatDateTimeFormat(d);
                    to_date = defaultEnd;
                }
                if (str == "yesterday") {
                    d.setDate(d.getDate() - 1);
                    from_date = this.formatDateTimeFormat(d);
                    this.setDayLastTime(d);
                    to_date = this.formatDateTimeFormat(d);
                }

                if (str == "7days") {
                    d.setDate(d.getDate() - 6);
                    from_date = this.formatDateTimeFormat(d);
                    to_date = defaultEnd
                }
                if (str == "month") {
                    d.setMonth(d.getMonth() - 1);
                    from_date = this.formatDateTimeFormat(d);
                    to_date = defaultEnd
                }
                if (str == "absToday") {
                    from_date = this.formatDateTimeFormat(d);
                    this.setDayLastTime(d);
                    to_date = this.formatDateTimeFormat(d);
                }

                if (str == "absToday+") {
                    this.setZeroTime(d);
                    d.setHours(10);
                    from_date = this.formatDateTimeFormat(d);
                    d.setDate(d.getDate() + 1);
                    to_date = this.formatDateTimeFormat(d);
                }

                this.bindDate("GET_opTime", "LET_opTime", { maxDate: to_date, maxDateTime: new Date(to_date.replace(/-/g, "/")), minDate: from_date, minDateTime: new Date(from_date.replace(/-/g, "/"))})
                $("input[name=GET_opTime]").datetimepicker("setDate", new Date(from_date.replace(/-/g, "/")));
                $("input[name=LET_opTime]").datetimepicker("setDate", new Date(to_date.replace(/-/g, "/")));
            },
            isValidVideoImage: function (filetype) {
                return $.inArray(filetype.toLowerCase(), ["jpg", "png"]) >= 0;
            },
            isValidImage: function (filetype) {
                return $.inArray(filetype.toLowerCase(), ["bmp", "jpg", "jpeg", "png", "tiff", "gif", "pcx", "tga", "exif", "fpx", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "wmf"]) >= 0;
            },
            isValidVideo: function (filetype) {
                return $.inArray(filetype.toLowerCase(), ["wmv", "asf", "asx", "rm", "rmvb", "mpg", "mpeg", "mpe", "3gp", "mov", "mp4", "m4v", "avi", "dat", "mkv", "flv", "vob", "ts"]) >= 0;
            },
            verifyForm: function (data, type) {
                var self = this;
                var checkArr = [];

                switch (type) {
                    case 0:
                        checkArr.push({value: data.address, error: "请上传一个视频素材", type: "not_empty"});
                        checkArr.push({value: data.picAddress, error: "请上传一张封面图", type: "not_empty"});
                        checkArr.push({value: data.name, error: "请填写新文件名 ", type: "not_empty"});
                        checkArr.push({value: data.duration, error: "请填写视频时长", type: "not_empty"});
                        checkArr.push({value: data.duration, error: "视频时长格式错误", type: "number"});
                        checkArr.push({value: data.duration, error: "中插视频时长不能大于120秒", type: "le", other: 120});
                        break;
                    case 1:
                        checkArr.push({value: data.picAddress, error: "请上传一个图片素材", type: "not_empty"});
                        checkArr.push({value: data.name, error: "请填写新文件名 ", type: "not_empty"});
                        break;
                }
                checkArr.push({value: Com.string.getStrLength(data.name), error: "新文件名不能超过40个字", type: "le", other: 80});
                checkArr.push({value: Com.string.getStrLength(data.remark), error: "备注不能超过100个字", type: "le", other: 200});
                checkArr.push({value: data.fileType, error: "文件类型不能为空", type: "not_empty"});
                checkArr.push({value: data.fileSize, error: "文件大小不能为空", type: "not_empty"});
                if (checkArr.length > 0) {
                    return EpgWeb.Plugin.Validate.batchCheck(checkArr);
                }
                return true;
            },
            startUploadFile: function (params, callback) {
                var self = this;
                var url = Vodad.Config.UPLOAD_URL;
                url = url + "?t=1";

                $.each(params, function (k, v) {
                    url = url + "&" + k + "=" + v;
                });
                $("#dlg_upload_waiting").dialog("moveToTop").dialog("open");
                $.ajax({
                    url: url,
                    method: "post",
                    cache: false,
                    contentType: false,
                    processData: false,
                    xhr: function () {
                        var xhr = jQuery.ajaxSettings.xhr();
                        return xhr;
                    },
                    data: params.file,
                    success: function (data) {
                        if (data.code == "A00000") {
                            console.log("success upload");
                            callback.call(this, data.data, params);
                        }
                        $("#dlg_upload_waiting").dialog("close");
                    },
                    error: function (data) {
                        $("#dlg_upload_waiting").dialog("close");
                    }
                })
            },
            startUploadVideo: function (params, callback) {
                var self = this;
                //当前时间戳
                var timestamp = Date.parse(new Date()) / 1000;
                var data = Vodad.Config.UPLOAD_VIDEO_PARAMS;
                var url = data.url + params.file.name;
                var sign = md5(data.access_key + url + "PUT" + data.secret_key + parseInt(timestamp/data.ttl));
                //console.log("access_key=" + data.access_key + " | url=" + data.url + " | http_method=PUT | secret_key=" + data.secret_key + " | quotient=" + parseInt(timestamp/data.ttl));
                //console.log("sign=" + sign);
                url = url + "?access=" + data.access_key + "&ttl=" + data.ttl + "&sign=" + sign;
                $("#dlg_upload_progress").dialog("moveToTop").dialog("open");

                $.ajax({
                    url: url,
                    method: "put",
                    cache: false,
                    contentType: false,
                    processData: false,
                    xhr: function () {
                        var xhr = jQuery.ajaxSettings.xhr();
                        xhr.upload.addEventListener("progress" , self.progressFunction, false);
                        return xhr;
                    },
                    data: params.file,
                    success: function (data) {
                        if (data.uuid != null) {
                            console.log("success upload");
                            callback.call(this, data, params);
                        }
                        $('#dlg_upload_progress .progress-bar').css('width', '0%');
                        $("#dlg_upload_progress").dialog("close");
                    },
                    error: function (data) {
                        $('#dlg_upload_progress .progress-bar').css('width', '0%');
                        $("#dlg_upload_progress").dialog("close");
                    }
                })
            },
					
            //上传进度实现方法，上传过程中会频繁调用该方法
            progressFunction: function (evt) {
                // event.total是需要传输的总字节，event.loaded是已经传输的字节。如果event.lengthComputable不为真，则event.total等于0
                if (evt.lengthComputable) {//
                    var progress = Math.round(evt.loaded / evt.total * 100);
                    $('#dlg_upload_progress .progress-bar').css('width', progress + '%');
                    $('#percentage').text(evt.loaded + " / " + evt.total);
                    $('#progressPercent').text(progress + '%');
                }
            },
            delUploadVideo: function (uuid) {
                var self = this;
                //当前时间戳
                var timestamp = Date.parse(new Date()) / 1000;
                var data = Vodad.Config.UPLOAD_VIDEO_PARAMS;
                var url = data.url + uuid;
                var sign = md5(data.access_key + url + "DELETE" + data.secret_key + parseInt(timestamp/data.ttl));
                url = url + "?access=" + data.access_key + "&ttl=" + data.ttl + "&sign=" + sign;
                $.ajax({
                    url: url,
                    method: "delete",
                    cache: false,
                    contentType: false,
                    success: function (data) {
                        console.log(data);
                    },
                    error: function (data) {
                    }
                })
            },
		});
});
define(
    '../vodad/Vodad.Grid',['require','exports','module'],function(require, exports, module) {

        Vodad.Grid = function(options) {
            this.dao = Vodad.Dao;
            this.config = Vodad.Config;
            this.util = Vodad.Util;
            this.options = options || {};
			//this.channel_id = Com.url.getQueryValue("channel_id",location.href);
			//this.channel_name = Com.url.getQueryValue("channel_name",location.href);
            this.construct = options.construct || function() {
                this.init();
            };
            this.construct.call(this);
        };

        Com.inherits(Vodad.Grid, Ancestor.Grid).extend({
            init: function() {
                var self = this;
                var $container = self.options.$container;
                self.$grid = $container.find('table.grid');
                self.initDialog();
                self.bindBasicEvent();
                self.initSuggest();
            },


            bindBasicEvent: function() {
                var self = this;

                var $container = self.options.$container;
                var $form = $container.find('form[name="basicFrm"]');
                $form.find('input[name="GET_opTime"]').datetimepicker({
                    onClose: function(selectedDate) {
                        $form.find('input[name="GET_opTime"]').timepicker("option", selectedDate);
                    }
                });
                $form.find('input[name="LET_opTime"]').datetimepicker({
                    onClose: function(selectedDate) {
                        $form.find('input[name="LET_opTime"]').timepicker("option", selectedDate);
                    }
                });
                $container.find('.query-add-vod').click(function() {
                    $("#dlg_upload_video").dialog("open");
                });

                 $container.find('.query-add-image').click(function() {
                    $("#dlg_upload_image").dialog("open");
                });

                $container.find('.query-btn').on('click.query', function() {
                    self.query();
                    return false;
                });

                $('.uploadBtnVideo').bind("change", function (e) {
                    e.preventDefault();
                    var $containerVideo = $("#dlg_upload_video");
                    $containerVideo.find('input[name="opTime"]').val(new Date().format("yyyy-MM-dd hh:mm:ss"));
                    var file = e.target.files[0];
                    var url = Com.file.getObjectURL(file);

                    var params = {};
                    params.file_type = Com.file.getExt(file.name);
                    params.file_size = file.size;

                    params.file = file;

                    $(this).val('');
                    if (params.file_size > 15 * 1024 * 1024 * 1024) {
                        EpgWeb.Plugin.showTips({content: "上传视频大小不允许超过15G, 请重新上传", type: "error"});
                        return;
                    }
                    if (!Vodad.Util.isValidVideo(params.file_type)) {
                        EpgWeb.Plugin.showTips({content: "暂时不支持该格式文件上传，请重新选择素材", type: "error"});
                        return;
                    }

                    Vodad.Util.startUploadVideo(params, self.uploadVideoFun);
                });

                $('.uploadBtnVideoImage').bind("change", function (e) {
                    var $containerVideo = $("#dlg_upload_video");
                    var file = e.target.files[0];
                    var url = Com.file.getObjectURL(file);

                    var params = self.config.EffectUploadCommonParams;

                    params.business_type = "image";
                    params.file_type = Com.file.getExt(file.name);
                    params.file_size = file.size;

                    params.file = file;

                    $(this).val('');
                    if (params.file_size > 3 * 1024 *1024) {
                        EpgWeb.Plugin.showTips({content: "上传封面图大小不允许超过3M, 请重新上传", type: "error"});
                        return;
                    }
                    if (!Vodad.Util.isValidImage(params.file_type)) {
                        EpgWeb.Plugin.showTips({content: "上传封面图格式只支持jpg|png, 请重新上传", type: "error"});
                        return;
                    }

                    Vodad.Util.startUploadFile(params, self.uploadPicFun);

                });

                $('.uploadBtnImage').bind("change", function (e) {
                    var $containerImage = $("#dlg_upload_image");
                    $containerImage.find('input[name="opTime"]').val(new Date().format("yyyy-MM-dd hh:mm:ss"));
                    var file = e.target.files[0];
                    var url = Com.file.getObjectURL(file);

                    var params = self.config.EffectUploadCommonParams;

                    params.business_type = "image";
                    params.file_type = Com.file.getExt(file.name);
                    params.file_size = file.size;

                    params.file = file;

                    $(this).val('');
                    if (params.file_size > 20 * 1024 *1024) {
                        EpgWeb.Plugin.showTips({content: "上传图片大小不允许超过20M, 请重新上传", type: "error"});
                        return;
                    }
                    if (!Vodad.Util.isValidImage(params.file_type)) {
                        EpgWeb.Plugin.showTips({content: "上传图片格式不支持, 请重新上传", type: "error"});
                        return;
                    }

                    Vodad.Util.startUploadFile(params, self.uploadImageFun);

                });
			},

			initDialog: function () {
			    var self = this;
			    $("#dlg_upload_video").dialog({
                     title: "上传视频",
                     autoOpen: false,
                     width: 680,
                     height: 450,
                     modal: true,
                     resizable: false,
                     buttons: [
                         {
                             text: "确定",
                             click: function () {
                                var data = {};
                                var $containerVideo = $("#dlg_upload_video");
                                data["name"] = $containerVideo.find('input[name="name"]').val();
                                data["fileType"] = $containerVideo.find('input[name="fileType"]').val();
                                data["fileSize"] = $containerVideo.find('input[name="fileSize"]').val();
                                data["address"] = $containerVideo.find('input[name="address"]').val();
                                data["picAddress"] = $containerVideo.find('input[name="picAddress"]').val();
                                data["opTime"] = $containerVideo.find('input[name="opTime"]').val();
                                data["opUser"] = $("div.user a.name").html();
                                data["contentType"] = $containerVideo.find('select[name="contentType"]').val();
                                data["duration"] = $containerVideo.find('input[name="duration"]').val();
                                data["remark"] = $containerVideo.find('input[name="remark"]').val();
                                data["type"] = 0;
                                if (!Vodad.Util.verifyForm(data, data.type)) {
                                    return;
                                }
                                Vodad.Dao.add({"data": JSON.stringify(data)}, function(data) {
                                    if (data != null && data.code == "A00000") {
                                        $('.query-btn').click();
                                        var $containerVideo = $("#dlg_upload_video");
                                        $containerVideo.find('input[name="name"]').val("");
                                        $containerVideo.find('input[name="fileType"]').val("");
                                        $containerVideo.find('input[name="fileSize"]').val("");
                                        $containerVideo.find('input[name="address"]').val("");
                                        $containerVideo.find('input[name="picAddress"]').val("");
                                        $containerVideo.find('input[name="opTime"]').val("");
                                        $containerVideo.find('select[name="contentType"]').val(1);
                                        $containerVideo.find('input[name="duration"]').val("");
                                        $containerVideo.find('input[name="remark"]').val("");
                                        $containerVideo.dialog("close");
                                        console.log("VODAD save successed !");
                                    }
                                });
                             }
                         },
                         {
                             text: "取消",
                             click: function () {
                                var $containerVideo = $("#dlg_upload_video");
                                $containerVideo.find('input[name="name"]').val("");
                                $containerVideo.find('input[name="fileType"]').val("");
                                $containerVideo.find('input[name="fileSize"]').val("");
                                $containerVideo.find('input[name="address"]').val("");
                                $containerVideo.find('input[name="picAddress"]').val("");
                                $containerVideo.find('input[name="opTime"]').val("");
                                $containerVideo.find('select[name="contentType"]').val(1);
                                $containerVideo.find('input[name="duration"]').val("");
                                $containerVideo.find('input[name="remark"]').val("");
                                $(this).dialog("close");
                             }
                         }
                     ]
                 });
                 $("#dlg_upload_image").dialog({
                      title: "上传图片",
                      autoOpen: false,
                      width: 680,
                      height: 450,
                      modal: true,
                      resizable: false,
                      buttons: [
                          {
                              text: "确定",
                              click: function () {
                                var data = {};
                                var $containerImage = $("#dlg_upload_image");
                                data["name"] = $containerImage.find('input[name="name"]').val();
                                data["fileType"] = $containerImage.find('input[name="fileType"]').val();
                                data["fileSize"] = $containerImage.find('input[name="fileSize"]').val();
                                data["picAddress"] = $containerImage.find('input[name="picAddress"]').val();
                                data["opTime"] = $containerImage.find('input[name="opTime"]').val();
                                data["opUser"] = $("div.user a.name").html();
                                data["contentType"] = $containerImage.find('select[name="contentType"]').val();
                                data["remark"] = $containerImage.find('input[name="remark"]').val();
                                data["type"] = 1;
                                if (!Vodad.Util.verifyForm(data, data.type)) {
                                    return;
                                }
                                Vodad.Dao.add({"data": JSON.stringify(data)}, function(data) {
                                  if (data != null && data.code == "A00000") {
                                      $('.query-btn').click();
                                      var $containerImage = $("#dlg_upload_image");
                                      $containerImage.find('input[name="name"]').val("");
                                      $containerImage.find('input[name="fileType"]').val("");
                                      $containerImage.find('input[name="fileSize"]').val("");
                                      $containerImage.find('input[name="picAddress"]').val("");
                                      $containerImage.find('input[name="opTime"]').val("");
                                      $containerImage.find('select[name="contentType"]').val(1);
                                      $containerImage.find('input[name="remark"]').val("");
                                      $containerImage.dialog("close");
                                      console.log("VODAD save successed !");
                                  }
                                });
                              }
                          },
                          {
                              text: "取消",
                              click: function () {
                                var $containerImage = $("#dlg_upload_image");
                                $containerImage.find('input[name="name"]').val("");
                                $containerImage.find('input[name="fileType"]').val("");
                                $containerImage.find('input[name="fileSize"]').val("");
                                $containerImage.find('input[name="picAddress"]').val("");
                                $containerImage.find('input[name="opTime"]').val("");
                                $containerImage.find('select[name="contentType"]').val(1);
                                $containerImage.find('input[name="remark"]').val();
                                $(this).dialog("close");
                              }
                          }
                      ]
                  });

                $("#dlg_upload_waiting").dialog({
                    autoOpen: false,
                    width: 300,
                    height: 150,
                    modal: true,
                    dialogClass: 'alert',
                    resizable: false,

                });

                $("#dlg_upload_progress").dialog({
                    autoOpen: false,
                    width: 450,
                    height: 150,
                    modal: true,
                    dialogClass: 'alert',
                    resizable: false,
                });
                 $("div.ui-dialog-buttonset").find("button:eq(0)").addClass("btn btn-primary");
                 $("div.ui-dialog-buttonset").find("button:eq(1)").addClass("btn");
			},

			bindFormEvent: function($form) {
                var self = this;

			},

            run: function(options, callback) {
                var self = this;
                var gridConfig = self.getGridConfig();
                options = $.extend(true, {
                    width: 1700,
                   // multiselect: true,
                    //multiselectWidth: 30,
                    shrinkToFit: false,
                    // idPrefix: 'Video-',
                    autowidth: false
                }, gridConfig, options);
                self.$grid.jqGrid(options);

              //  self.initGrid.call(this, options, callback);
                self.$grid.jqGrid('setGridParam', {
                    postData: {},
                }).trigger('reloadGrid', [{
                    page: 1
                }]);
            },

            getParam: function() {
                var self = this;
                var $container = self.options.$container;

                var $grid = self.$grid;
                var params = {};
                var $form = $container.find('form[name="basicFrm"]');

                var $elements = $.makeArray($form.prop('elements')).filter(function(item) {
					return true;
                });

				var checkboxVal = [];
                var name,type;
                var key;
                $.each($elements, function() {
                    name = this.name;
                    type = this.nodeName;
                    if (name) {
                        if (type=='SELECT') {
                            if ($(this).val() != "all") {
                                params[name] = $.trim($(this).val());
                            }
                        } else {
                            if($(this).val()){
                                params[name] = $.trim($(this).val());
                            }
                        }
                    }
                });
                return params;
            },

            query: function() {
                var self = this;
                var $container = self.options.$container;
                var $grid = self.$grid;
                self.overridePostData($grid);
                var data = self.getParam();
                var checkArr = [];
                if (data.GET_opTime != null) {
                    checkArr.push({value: data.GET_opTime, error: "上传开始时间格式错误", type: "date"});
                }
                if (data.LET_opTime != null) {
                    checkArr.push({value: data.LET_opTime, error: "上传结束时间格式错误", type: "date"});
                }
                if (checkArr.length > 0) {
                    if (!EpgWeb.Plugin.Validate.batchCheck(checkArr)) {
                        return false;
                    }
                }
                var params = {"paramsObj": JSON.stringify(data)};
                var checkArr = [];

                $grid.jqGrid('setGridParam', {
                    postData: params,
                }).trigger('reloadGrid', [{
                    page: 1
                }]);
            },

            uploadVideoFun: function (data, params) {
                var self = this;
                var $containerVideo = $("#dlg_upload_video");
                var name = params.file.name;
                $containerVideo.find('input[name="name"]').val(name.substring(0, name.lastIndexOf(".")));
                $containerVideo.find('input[name="fileType"]').val(params.file_type);
                $containerVideo.find('input[name="fileSize"]').val(params.file_size);
                $containerVideo.find('input[name="address"]').val(Vodad.Config.UPLOAD_VIDEO_PARAMS.url + data.uuid);
            },
            uploadPicFun: function (data, params) {
                var self = this;
                var $containerVideo = $("#dlg_upload_video");
                $containerVideo.find('input[name="picAddress"]').val(data.httpInnerUrl);
            },
            uploadImageFun: function (data, params) {
                var self = this;
                var $containerImage = $("#dlg_upload_image");
                var name = params.file.name;
                $containerImage.find('input[name="name"]').val(name.substring(0, name.lastIndexOf(".")));
                $containerImage.find('input[name="fileType"]').val(params.file_type);
                $containerImage.find('input[name="fileSize"]').val(params.file_size);
                $containerImage.find('input[name="picAddress"]').val(data.httpInnerUrl);
            },
            initSuggest: function () {
                var emailSuggest = {
                    options: {
                        source: "/api/redirect",
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            var val = this.element.val(),
                                ret = []
                            return ret;
                        },
                        getParam: function (term) {
                            var requestData = {url: "http://lego.iqiyi.com/external/auth/auth-api/services/user/search", type: "get", params: {email: term}, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = json.data == null ? null : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["userName"];
                                itemData[options.labelKey] = item["email"];
                                itemData["value"] = item["userName"]
                                itemData["email"] = item["email"];
                                itemData["uid"] = item["uid"];
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item.id + "(" + item.label + ")";
                        }
                    }
                }
                $("input[name=EQS_opUser]").suggest(emailSuggest.options);

                var nameSuggest = {
                    options: {
                        source: "/api/vod/ad/getList",
                        method: "post",
                        multiple: false,
                        clearInvalid: false,
                        parseValue: function () {
                            var val = this.element.val(),
                                ret = []
                            return ret;
                        },
                        getParam: function (term) {
                            var requestData = {LIKES_name: term};
                            return {"paramsObj": JSON.stringify(requestData)}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = json.data.result == null ? null : json.data.result;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["name"];
                                itemData[options.labelKey] = item["name"];
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item.label;
                        }
                    }
                }
                $("input[name=LIKES_name]").suggest(nameSuggest.options);
            },
        });

    }
);
define(
	'../server/Server',['require','exports','module'],function(require, exports, module){
		window.Server = window.Server || { version : '1.0' };
		//Video公共配置集合，键值对象
		Server.Config = Server.Config || {};
		Server.Util = Server.Util || {};

        Server.Constant = {
            devMode: auth.dev()
        }
	}
);
define(
	'../server/Server.Action',['require','exports','module'],function(require, exports, module){

        Server.Action = (function() {
			var serverGrid = null;
            var getServerGrid = function(options) {
                if (!serverGrid) {

                    serverGrid = new Server.Grid($.extend(true, {
                        '$container': $('#ServerListContainer'),
                        type: 0
                    }, options));
                }
                return serverGrid;
            };
            var serverGridRun = function(options) {
                serverGrid = getServerGrid(options);
                serverGrid.run();
            };
			var run = function() {
                /* videoQueryRun();*/
                serverGridRun({});
            };
            var editBase = null;
            var getEditBase = function(options) {

                if (!editBase) {
                    editBase = new Server.Edit(options);
                }
                return editBase;
            };
            var editRun = function() {
                var $container = $('.video-edit-form');
                getEditBase({
                    $container: $container
                }).run();
            };

            var versionBase = null;

            var versionRun = function () {
                var $container = $('#VersionListContainer');
                getVersionBase({
                    $container: $container
                }).run();
            }
            var getVersionBase = function(options) {

                if (!versionBase) {
                    versionBase = new Server.Version(options);
                }
                return versionBase;
            };

            var editClusterBase = null;
            var getEditClusterBase = function(options) {

                if (!editClusterBase) {
                    editClusterBase = new Server.ClusterEdit(options);
                }
                return editClusterBase;
            };
            var editClusterBaseRun = function() {
                var $container = $('.video-edit-form');
                getEditClusterBase({
                    $container: $container
                }).run();
            };

            var clusterBase = null;
            var getClusterBase = function(options) {

                if (!clusterBase) {
                    clusterBase = new Server.ClusterList(options);
                }
                return clusterBase;
            };
            var clusterBaseRun = function() {
                var $container = $('#ClusterListContainer');
                getClusterBase({
                    $container: $container
                }).run();
            };

            return {
                run: run,
				editRun:editRun,
				getServerGrid:getServerGrid,
                versionRun:versionRun,
                editClusterBaseRun:editClusterBaseRun,
                clusterBaseRun:clusterBaseRun
            };
        })();
	}
);
define('../server/Server.Config',['require','exports','module'],function(require, exports, module) {

    Server.Config = $.extend({}, Ancestor.Config, {



        SERVER_STATUS: ['下线', '上线','测试'],
        SERVER_TYPE: ['PGC直转点','UDI','UGC直转点','测试','轮播台','视频包装系统','秀场服务','直播编码','直播收录','直转点','直转点列表','导播台','新收录','包装系统-直转点','包装系统-导播台'],
        ZZD_SERVER_STATUS: ['服务异常','版本缺失','正常','版本不同'],
        INCLUDE_TYPE : 12,


        REGION_CH_LIST: [],
        PageBean: null,
        URL_PRE : 'http://',
        URL_POST : ':8080/version',

        VERSION_IND : {
            'zzdVersion': 3,
            'encoderVersion': 4,
            'mergeToolVersion': 5,
            'mergeServiceVersion': 6,
            'precisionCutToolVersion': 7,
            'hardware':0,
            'serverStatus':2,
            'versionStatus':1
        },

        validator: {
            messages: {
                sn: {
                    required: "序列号不能为空",
                },
                insideServerIp: {
                    required: "内网IP不能为空",
                },
                status: {
                    required: '服务器状态不能为空',
                },
                serverType: {
                    required: '服务器类型不能为空',
                },
                idc: {
                    required: '机房不能为空',
                },
                system: {
                    required: '系统不能为空',
                },
                including: {
                    required: '最大收录数不能为空',
                }
            },
            rules: {
                sn: {
                    required: true,
                },
                insideServerIp: {
                    required: true,
                },
                status: {
                    required: true,
                },
                serverType: {
                    required: true,
                },
                idc: {
                    required: true,
                },
                system: {
                    required: true,
                },
                including:{
                    required: true,
                }
            }
        },

			TABLE_COLMODEL_CONFIG: {
			    'sn': {
                    name: 'sn',
                    title: false,
                    index: 'sn',
                    align:'center',
                    sortable: false,
                    width: 90
                },
				'insideServerIp': {
					name: 'insideServerIp',
					title: false,
					index: 'insideServerIp',
					align:'center',
					sortable: false,
					width: 90,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.IPtoHubble(v,r);
                    }
				},
				'outsideServerIp': {
					name: 'outsideServerIp',
					title: false,
					index: 'outsideServerIp',
					align:'center',
					sortable: false,
					width: 90
				},
				'port': {
					name: 'port',
					title: false,
					index: 'port',
					align:'center',
					sortable: false,
					width: 50
				},
				'serverType': {
                    name: 'serverType',
                    title: false,
                    index: 'serverType',
                    align:'center',
                    sortable: false,
                    width: 100,
                    align: 'center',
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.serverType(v,r);
                    }
                },
                'idc': {
                    name: 'idc',
                    title: false,
                    index: 'idc',
                    align:'center',
                    sortable: false,
                    width: 120,
                    align: 'center',
                },

                'cluster_name': {
                    name: 'cluster_name',
                    title: false,
                    index: 'cluster_name',
                    align:'center',
                    sortable: false,
                    width: 120,
                    align: 'center',
                    formatter: function(v, o, r) {
                        return Server.Util.formatClusterName(v,r);
                    }
                },
                /*
                'province': {
                    name: 'province',
                    title: false,
                    index: 'province',
                    align:'center',
                    sortable: false,
                    width: 100
                },
                'city': {
                    name: 'city',
                    title: false,
                    index: 'city',
                    align:'center',
                    sortable: false,
                    width: 100
                },
                */
                'system': {
                    name: 'system',
                    title: false,
                    index: 'system',
                    align:'center',
                    sortable: false,
                    width: 80
                },
                'hardware': {
                    name: 'hardware',
                    title: false,
                    index: 'hardware',
                    align:'center',
                    sortable: false,
                    width: 80
                },
				'status': {
					name: 'status',
					title: false,
					index: 'status',
					align:'center',
					width: 50,
					sortable: false,
					formatter: function(v, o, r) {
						return Server.Util.formatter.status(v,r);
					}
				},

				'remark': {
					name: 'remark',
					title: false,
					index: 'remark',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'operate': {
					name: 'operate',
					title: false,
					index: 'operate',
					width: 80,
					align:'center',
					sortable: false,
					formatter: function(v, o, r) {
						return Server.Util.formatter.operate(v,r);
					}
				},
                'details': {
                    name: 'details',
                    title: false,
                    index: 'details',
                    width: 55,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.details(v,r);
                    }
                },

                'load': {
                    name: 'load',
                    title: false,
                    index: 'load',
                    width: 50,
                    align:'center',
                    sortable: true,
                    hidden:true
                },

                'dataFreePer': {
                    name: 'dataFreePer',
                    title: false,
                    index: 'dataFreePer',
                    width: 80,
                    align:'center',
                    sortable: true,
                    hidden:true,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },

                'allFreePer': {
                    name: 'allFreePer',
                    title: false,
                    index: 'allFreePer',
                    width: 80,
                    align:'center',
                    sortable: true,
                    hidden:true,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },


                'availableMemPer': {
                    name: 'availableMemPer',
                    title: false,
                    index: 'availableMemPer',
                    width: 80,
                    align:'center',
                    sortable: true,
                    hidden:true,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },


                'freeSwapPer': {
                    name: 'freeSwapPer',
                    title: false,
                    index: 'freeSwapPer',
                    width: 100,
                    align:'center',
                    sortable: true,
                    hidden:true,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },

                'inIcmploss': {
                    name: 'inIcmploss',
                    title: false,
                    index: 'inIcmploss',
                    width: 100,
                    align:'center',
                    sortable: true,
                    //hidden:true,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatLoss(v,r);
                    }
                },

                'outIcmploss': {
                    name: 'outIcmploss',
                    title: false,
                    index: 'outIcmploss',
                    width: 100,
                    align:'center',
                    sortable: true,
                    hidden:true,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatLoss(v,r);
                    }
                },
                'disk': {
                    name: 'disk',
                    title: false,
                    index: 'disk',
                    width: 100,
                    align:'center',
                    sortable: false
                },
                'monitor': {
                    name: 'monitor',
                    title: false,
                    index: 'monitor',
                    width: 80,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatMonitor(v,r);
                    }
                },
                'men': {
                    name: 'men',
                    title: false,
                    index: 'men',
                    width: 100,
                    align:'center',
                    sortable: false
                },
                'networkStatus': {
                    name: 'networkStatus',
                    title: false,
                    index: 'networkStatus',
                    width: 100,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.networkStatus(v,r);
                    }
                },
                'addTime': {
                    name: 'addTime',
                    title: false,
                    index: 'addTime',
                    align:'center',
                    width: 100,
                    sortable: false,
                    align: 'center',
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.time(v,r);
                    }
                },

			},

            TABLE_VERSION_COLMODEL_CONFIG: {
                //colModel: ["serverId","insideServerIp","outsideIp","zzdVersion","encoderVersion","mergeToolVersion","mergeServiceVersion","precisionCutToolVersion","hardware","serverStatus","updateTime",'detail'],
                'serverId': {
                    name: 'serverId',
                    title: false,
                    index: 'serverId',
                    align:'center',
                    sortable: false,
                    width: 80,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.id(v,r);
                    }
                },

                'insideServerIp': {
                    name: 'insideServerIp',
                    title: false,
                    index: 'insideServerIp',
                    align:'center',
                    sortable: false,
                    width: 100,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.insideServerIp(v,r);
                    }
                },

                'outsideIp': {
                    name: 'outsideIp',
                    title: false,
                    index: 'outsideIp',
                    align:'center',
                    sortable: false,
                    width: 100
                },

                'zzdVersion': {
                    name: 'zzdVersion',
                    title: false,
                    index: 'zzdVersion',
                    width: 100,
                    align:'center',
                    sortable: false
                },

                'hardware': {
                    name: 'hardware',
                    title: false,
                    index: 'hardware',
                    width: 100,
                    align:'center',
                    sortable: false
                },

                'encoderVersion': {
                    name: 'encoderVersion',
                    title: false,
                    index: 'encoderVersion',
                    width: 100,
                    align:'center',
                    sortable: false
                },
                'mergeToolVersion': {
                    name: 'mergeToolVersion',
                    title: false,
                    index: 'mergeToolVersion',
                    width: 100,
                    align:'center',
                    sortable: false
                },
                'mergeServiceVersion': {
                    name: 'mergeServiceVersion',
                    title: false,
                    index: 'mergeServiceVersion',
                    width: 100,
                    align:'center',
                    sortable: false
                },
                'precisionCutToolVersion': {
                    name: 'precisionCutToolVersion',
                    title: false,
                    index: 'precisionCutToolVersion',
                    width: 140,
                    align:'center',
                    sortable: false
                },
                'serverStatus': {
                    name: 'serverStatus',
                    title: false,
                    index: 'serverStatus',
                    width: 100,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.zzd_status(v,r);
                    }
                },
                'updateTime': {
                    name: 'updateTime',
                    title: false,
                    index: 'updateTime',
                    width: 130,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.time(v,r);
                    }
                },

                'remark': {
                    name: 'remark',
                    title: false,
                    index: 'remark',
                    width: 140,
                    align:'center',
                    sortable: false,
                },

                'status': {
                    name: 'status',
                    title: false,
                    index: 'status',
                    align:'center',
                    width: 100,
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.status(v,r);
                    }
                },

                'detail': {
                    name: 'insideServerIp',
                    title: false,
                    index: 'insideServerIp',
                    width: 90,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.detail(v,r);
                    }
                },
            },

            TABLE_STATUS_COLMODEL_CONFIG: {
                'addTime': {
                    name: 'addTime',
                    title: false,
                    index: 'addTime',
                    align:'center',
                    width: 100,
                    sortable: false,
                    align: 'center',
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.time(v,r);
                    }
                },
                'load': {
                    name: 'load',
                    title: false,
                    index: 'load',
                    width: 50,
                    align:'center',
                    sortable: false
                },

                'dataFreePer': {
                    name: 'dataFreePer',
                    title: false,
                    index: 'dataFreePer',
                    width: 80,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },

                'allFreePer': {
                    name: 'allFreePer',
                    title: false,
                    index: 'allFreePer',
                    width: 80,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },


                'availableMemPer': {
                    name: 'availableMemPer',
                    title: false,
                    index: 'availableMemPer',
                    width: 80,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },


                'freeSwapPer': {
                    name: 'freeSwapPer',
                    title: false,
                    index: 'freeSwapPer',
                    width: 100,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatPer(v,r);
                    }
                },

                'inIcmploss': {
                    name: 'inIcmploss',
                    title: false,
                    index: 'inIcmploss',
                    width: 100,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatLoss(v,r);
                    }
                },

                'outIcmploss': {
                    name: 'outIcmploss',
                    title: false,
                    index: 'outIcmploss',
                    width: 100,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Server.Util.formatter.formatLoss(v,r);
                    }
                },
            },


			TABLE: {
			    url: "/api/sginal/server/list",
			    rowNum: 50,
                pager: "#ServerListPager",
			    multiselect: false,
			    prmNames: {
                    page: "pageNo",
                    rows: "pageSize",
                    sort: 'OrderBy',
                    order: 'Sort'
                },

			    loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/sginal/server/list");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

			    //datatype: "local",
			    loadtext: '加载中...',
                loadui: "block",
                mtype: "post",
                loadonce: false,
                sortname:'load',
                sortorder:'none',


				colNames: ["序列号", "内网IP","外网IP", "端口号", "业务","集群", "机房", /*"省份", "市区",*/ "系统", "硬件", "描述", "状态","load","/data free","/ free","可用内存","swap空闲比","内icmploss","外icmploss", "详情","监控", "操作"],
				colModel: ['sn', 'insideServerIp','outsideServerIp', 'port', 'serverType','cluster_name',  'idc', /*'province', 'city', */'system','hardware', 'remark', 'status','load','dataFreePer','allFreePer','availableMemPer','freeSwapPer','inIcmploss','outIcmploss','details','monitor', 'operate' ]
			},


            TABLE_STATUS: {
                url: "/api/sginal/server/status/list",
                rowNum: 20,
                pager: "#status_pager",
                multiselect: false,
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

                loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/sginal/server/status/list");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

                //datatype: "local",
                loadtext: '加载中...',
                loadui: "block",
                mtype: "post",
                sortname:[],

                colNames: ["获取时间", "load","/data free","/ free","可用内存","swap空闲比","内icmploss","外icmploss"],
                colModel: ['addTime','load' ,'dataFreePer','allFreePer','availableMemPer','freeSwapPer','inIcmploss','outIcmploss']
            },

            TABLE_zzdServer: {
                url: "/api/sginal/server/zzdServerList",
                rowNum: 100,
                pager: "#VersionListPager",
                multiselect: false,
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

                loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/sginal/server/zzdServerList");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

                //datatype: "local",
                loadtext: '加载中...',
                loadui: "block",
                mtype: "post",

                colNames: ["ID","内网ip","外网ip","直转点版本号","编码器版本号","合并工具版本号","合并服务版本号","精确化裁剪工具版本号","硬件" ,"版本状态", "更新时间","描述","服务状态","详细"],
                colModel: ["serverId","insideServerIp","outsideIp","zzdVersion","encoderVersion","mergeToolVersion","mergeServiceVersion","precisionCutToolVersion","hardware","serverStatus","updateTime","remark","status","detail"],
            },











            CLUSTER_STATUS: ['下线', '上线'],
            clusterValidator: {
                errorClass: 'invalid-msg',
                highlight: function(element, errorClass) {
                    $(element).addClass('invalid-field');
                },
                unhighlight: function(element, errorClass) {
                    $(element).removeClass('invalid-field');
                },
            messages: {
                name: {
                    required: "集群名称不能为空",
                },
                status: {
                    required: '集群状态不能为空',
                },
                idc: {
                    required: '机房不能为空',
                },
            },
            rules: {
                name: {
                    required: true,
                },
                status: {
                    required: true,
                },
                idc: {
                    required: true,
                },
            }

        },

            TABLE_SERVER_IDCSERVER_COLMODEL_CONFIG: {
                'cluster_name':{
                    name: 'cluster_name',
                    title: false,
                    index: 'cluster_name',
                    align:'center',
                    width: 100,
                    sortable: false,
                    align: 'center',
                    formatter: function(v, o, r) {
                        return Server.Util.formatClusterName(v,r);
                    }
                },

                'insideServerIp': {
                    name: 'insideServerIp',
                    title: false,
                    index: 'insideServerIp',
                    align:'center',
                    width: 100,
                    sortable: false,
                    align: 'center',
                },
                'including': {
                    name: 'including',
                    title: false,
                    index: 'including',
                    width: 100,
                    align:'center',
                    sortable: false
                },
            },

            TABLE_SERVER_CLUSTER_COLMODEL_CONFIG: {
            'id':{
                name: 'id',
                title: false,
                index: 'id',
                align:'center',
                width: 100,
                sortable: false,
                align: 'center',
            },

            'name': {
                name: 'name',
                title: false,
                index: 'name',
                align:'center',
                width: 100,
                sortable: false,
                align: 'center',
            },
            'including': {
                name: 'including',
                title: false,
                index: 'including',
                width: 100,
                align:'center',
                sortable: false
            },

            'serverNum': {
                name: 'serverNum',
                title: false,
                index: 'serverNum',
                width: 100,
                align:'center',
                sortable: false
            },

            'user': {
                name: 'user',
                title: false,
                index: 'user',
                width: 100,
                align:'center',
                sortable: false,
                formatter: function(v, o, r) {
                    return Server.Util.formatUser(v,r);
                }
            },

            'addTime': {
                name: 'addTime',
                title: false,
                index: 'addTime',
                width: 150,
                align:'center',
                sortable: false
            },

            'status': {
                name: 'status',
                title: false,
                index: 'status',
                width: 100,
                align:'center',
                sortable: false,
                formatter: function(v, o, r) {
                    return Server.Util.formatClusterStatus(v,r);
                }
            },

            'operate': {
                name: 'operate',
                title: false,
                index: 'operate',
                width: 130,
                align:'center',
                sortable: false,
                formatter: function(v, o, r) {
                    return Server.Util.formatOpt(v,r);
                }
            },
        },

            TABLE_SERVER_IDCSERVER: {
                url: "/api/sginal/server/idcServerList",
                multiselect: true,
                rowNum: 300,
                height:400,

                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

                loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/sginal/server/idcServerList");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

                //datatype: "local",
                loadtext: '加载中...',
                loadui: "block",
                mtype: "post",

                colNames: ["IP","最大收录数","已分配集群"],
                colModel: ["insideServerIp","including","cluster_name"],
            },


            TABLE_SERVER_CLUSTER: {
                url: "/api/sginal/server/clusterList",
                rowNum: 20,
                pager: "#ClusterListPager",
                multiselect: false,
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

                loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/sginal/server/clusterList");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

                loadtext: '加载中...',
                loadui: "block",
                mtype: "post",

                colNames: ["服务器集群ID","服务器集群","服务器数量","已收录信号数","状态","创建人","创建时间","操作"],
                colModel: ["id","name","serverNum","including","status","user","addTime","operate"],
            },

		});
});
define(
	'../server/Server.Dao',['require','exports','module'],function(require, exports, module){

        Server.Dao = $.extend({}, Ancestor.Dao, {
            getList: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/list",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/list");
            },
            add: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/create",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        var subdata = JSON.parse(data["entity"]);

                        if(subdata["serverType"] == 9){
                            Server.Dao.synVersion(subdata);
                        }

                        callback.call(this, rdata);

                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/create");
            },

            edit: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/edit",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        var subdata = JSON.parse(data["entity"]);
                        if(subdata["serverType"] == 9){
                            Server.Dao.synVersion(subdata);
                        }
                        callback.call(this, rdata);

                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/edit");
            },
            delete: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/delete",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        Server.Dao.delVersionController(data);
                        callback.call(this, rdata);
                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/delete");
            },
            checkInsideIp: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/checkInsideServerIp",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        callback.call(this, rdata);
                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/checkInsideServerIp");
            },

            redirect: function(data, callback) {
                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options,'/redirect');
            },
            getZZDVersionList: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/zzdServerList",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/zzdServerList");
            },

            versionHistory: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/versionHistory",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/versionHistory");
            },

            synVersion : function(data,callback){
                var options = {
                    type: "post",
                    url: "/api/sginal/server/synVersion",
                    dataType: "json",
                    data: data,
                }
                Ancestor.Dao.ajax(options, "/sginal/server/synVersion");
            },

            delVersionController : function(data,callback){
                var options = {
                    type: "post",
                    url: "/api/sginal/server/delVersionController",
                    dataType: "json",
                    data: data,
                }
                Ancestor.Dao.ajax(options, "/sginal/server/delVersionController");
            },

            getMainVersion : function(data,callback){
                var options = {
                    type: "post",
                    url: "/api/sginal/server/getMainVersion",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/getMainVersion");
            },

            setMainVersion : function(data,callback){
                var options = {
                    type: "post",
                    url: "/api/sginal/server/setMainVersion",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/setMainVersion");
            },

            synVersionStatus : function(data,callback){
                var options = {
                    type: "post",
                    url: "/api/sginal/server/synVersionStatus",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/synVersionStatus");
            },






            
            addCluster: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/createServerCluster",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        callback.call(this, rdata);
                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/createServerCluster");
            },

            editCluster: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/editServerCluster",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        callback.call(this, rdata);
                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/editServerCluster");
            },
            clusterList: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/clusterList",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        callback.call(this, rdata);
                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/clusterList");
            },

            clusterServerList: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/clusterSeverList",
                    dataType: "json",
                    data: data,
                    success: function (rdata){
                        callback.call(this, rdata);
                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/clusterSeverList");
            },

            delServerCluster: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/server/delServerCluster",
                    dataType: "json",
                    data: data,
                    success: function (rdata) {
                        callback.call(this, rdata);
                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/server/delServerCluster");
            },

        });
	}
);
define('../server/Server.Util',['require','exports','module'],function(require, exports, module) {
	Server.Util = $.extend(true, {}, EpgWeb.Util, {
			formatter: {
			    status: function (v, r) {
                    return Server.Config.SERVER_STATUS[v];
                },
                insideServerIp: function(v, r){
                    if(v!=""){
                        return '<a target="_Blank" href= "zhibo_list.html?ip='+v+'">'+v+'</a>';
                    }

                },

                id: function(v, r){
                    if(v!=""){
                        return '<a target="_Blank" href= "server_home.html?id='+v+'">'+v+'</a>';
                    }

                },
                detail: function (v, r) {
                    return '<a target="_Blank" href="'+Server.Config.URL_PRE+v+Server.Config.URL_POST +'">详细</a>';
                },
                zzd_status: function (v, r) {
                    var status = Server.Config.ZZD_SERVER_STATUS[v];
                    if(v != 2){
                        return '<span style="color:red">'+status+'</span>';
                    }
                    return '<span>'+status+'</span>';
                },
                serverType: function (v, r) {
                    return Server.Config.SERVER_TYPE[v];
                },
                operate:function(v,r) {
                    var str = "<a href='/epg/server_edit.html?id=" + r.id + "' target='_blank'>修改</a>";
                    str += " | " + "<a href='javascript:void(0);' onclick='Server.Util.del(" + r.id + ")' target='_blank'>删除</a>";
                    return str;
                },
                formatPer:function(v,r) {
                    var str = '-1';
                    //console.log(v);
                    if(v&&v!='null'){
                        if(v[0]=='0'){
                            str = v.slice(1);
                        }else{
                            str = v;
                        }
                        if(str<20){
                            return '<span style="color:red;">'+str+'%</span>';
                        }

                        str+='%';
                    }
                    return str;
                },
                formatMonitor:function(v,r){
                    if(v==-2){
                        return '<span style="color: #FF0000">不通</span>';
                    }
                    if(v==-1){
                        return '<span style="color: #FF0000">多种异常</span>';
                    }
                    if(v==-0){
                        return '正常';
                    }
                    if(v==1){
                        return '<span style="color: #FF0000">/data异常</span>';
                    }
                    if(v==2){
                        return '<span style="color: #FF0000">/异常</span>';
                    }
                    if(v==3){
                        return '<span style="color: #FF0000">内存异常</span>';
                    }
                    if(v==4){
                        return '<span style="color: #FF0000">swap异常</span>';
                    }
                },

                formatLoss:function(v,r) {
                    $(v).css('background','red');
                    //alert($(r).html());
                    if(v=='0'){
                        return '<span style="font-weight: bold;color: #00FF00">✔</span>';
                    }else if(v=='100'){
                        return '<span style="font-weight: bold;color: #FF0000">✖</span>';
                    }
                    else{

                        return '-1';
                    }
                    return v;
                },

                formatSelect:function(v,r) {
                    $(v).css('background','red');
                    //alert($(r).html());
                    if(v=='0'){
                        return '<span style="font-weight: bold;color: #00FF00">✔</span>';
                    }else if(v=='100'){
                        return '<span style="font-weight: bold;color: #FF0000">✖</span>';
                    }
                    else{

                        return '-1';
                    }
                    return v;
                },

                IPtoHubble:function(v,r){
                    return '<a target="_blank" href="http://hubble.qiyi.domain/#/result?ip='+v+'">'+v+'</a>';
                },

                details:function(v,r) {
                    return "<a href='javascript:void(0);' data-id='" + r.id + "' onclick='Server.Util.serverStatusList(this);' class='btn btn-link'>详情</a>"
                },
                time: function (v, r) {
                    return v.substring(0, 19);
                },
                networkStatus:function(v,r) {
                    var str = "", green = "color: ForestGreen", red = "color: red";
                    if (r.inputStatus == 1) {
                        str += "<span style = '" + green + "'>内网ip</span>,";
                    } else if (r.inputStatus == 0) {
                        str += "<span style = '" + red + "'>内网ip</span>,";
                    }
                    if (r.outputStatus == 1) {
                        str += "<span style = '" + green + "'>外网ip</span>";
                    } else if (r.outputStatus == 0){
                        str += "<span style = '" + red + "'>外网ip</span>";
                    }
                    return str;
                }

            },

            del: function(id){
                var self = this;
                if(window.confirm('是否从服务器列表中删除该数据？')) {
                    var params = {id : id};
                    Server.Dao.delete(params, function(data){
                        if(data.code == 'A00000'){
                            Server.Util.logTips({type: "success", content: "删除成功"});
                            $('.query-btn').click();

                        }else if(data.code == 'A00001'){
                            if(data.data == '-1111'){
                                Server.Util.logTips({type: "error", content: "正在收录任务，不可删除"});
                            }else{
                                Server.Util.logTips({type: "error", content: "删除失败"});
                            }
                        }
                        
                    });
                    return true;
                }
            },

        logTips: function (options) {
            EpgWeb.Plugin.showTips(options);
        },

            serverStatusList: function(obj) {
                var self = this;
                var serverId = $(obj).attr('data-id');
                var params = {serverId: serverId};

                $('#serverStatusList').jqGrid('setGridParam', {
                    page: 1,
                    datatype: "json",
                    postData: params
                }).trigger('reloadGrid');
                self.openDlg($("#o-h-dlg"), '详情',1000 , 750);
            },

            versionHistory: function (selector,versionList) {
                $(selector).append($("<option>").html('全部').val(""));
                for(var index in versionList) {
                    var node = $("<option>").val(versionList[index]).html(versionList[index]);
                    $(selector).append(node);
                }
            },

            statusList: function (selector,statusList,type) {
                $(selector).append($("<option>").html('全部').val(""));
                if(type==Server.Config.VERSION_IND['serverStatus']){//status
                    for(var index in statusList) {
                        var node = $("<option>").val(statusList[index]).html(Server.Config.SERVER_STATUS[parseInt(statusList[index])]);
                        $(selector).append(node);
                    }
                }

                if(type==Server.Config.VERSION_IND['versionStatus']){//version status
                    for(var index in statusList) {
                        var node = $("<option>").val(statusList[index]).html(Server.Config.ZZD_SERVER_STATUS[parseInt(statusList[index])]);
                        $(selector).append(node);
                    }
                }


            },

            difMonitorNull: function(){
                $('#ServerListGrid').find("[role='row']").each(function(i,ele){
                    if(i!=0){
                        $(this).find('td').each(function(j,td){
                            if($(td).html()=='-1'){
                                $(td).css('background','#C0C0C0');
                                $(td).html("");
                            }

                        });
                    }
                });
            },

            difMainVersion: function(mainVersion){
                $('#VersionListGrid').find("[role='row']").each(function(i,ele){
                    if(i!=0){
                        $(this).find('td').each(function(j,td){
                            var ind = j-3;
                            if(ind>=0&&ind<5){
                                //console.log($(td).html()+"::"+ind);
                                if(mainVersion[ind]!=$(td).html()){
                                    $(td).css('color','red');
                                }
                            }

                        });
                    }
                });
            },

            getNewMainVersion: function($mdiv){
                var versions="";
                $mdiv.find('select').each(function () {
                    versions+=$(this).val()+",";
                });
                versions.slice(0,-1);
                return versions;
            },

            showDialog: function(versions){
                var $mdiv = $("#mainVersionDiv");
                $mdiv.find('select').each(function(i,elem){
                    $(elem).val(versions[i]);
                });
                $mdiv.dialog("open");
            },

            closeDialog: function(){
                var targetDiv = $("#mainVersionDiv");
                targetDiv.dialog("close");
            },

            loadOrder:function(order,$div){
                var $father = $div.find('span').eq(0);
                $father.css('display','inline');
                if(order=='none'){
                    $father.children().each(function(i,ele){
                        if(i==0){$(ele).attr('class','ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr');}
                        if(i==1){$(ele).attr('class','ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr');}
                    })
                }
                if(order=='asc'){
                    $father.children().each(function(i,ele){
                        if(i==0){$(ele).attr('class','ui-grid-ico-sort ui-icon-asc ui-icon ui-icon-triangle-1-n ui-sort-ltr');}
                        if(i==1){$(ele).attr('class','ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr');}
                    })
                }
                if(order=='desc'){
                    $father.children().each(function(i,ele){
                        if(i==0){$(ele).attr('class','ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr');}
                        if(i==1){$(ele).attr('class','ui-grid-ico-sort ui-icon-desc ui-icon ui-icon-triangle-1-s ui-sort-ltr');$(ele).css('color','red')}
                    });
                }
            },

            province: [
                        {
                            name:"北京市",
                            city:[
                                {
                                    name:"北京市",
                                    districtAndCounty:["东城区","西城区","崇文区","宣武区","朝阳区","丰台区","石景山区","海淀区","门头沟区","房山区","通州区","顺义区","昌平区","大兴区","怀柔区","平谷区","密云县","延庆县","延庆镇"]
                                }
                            ]
                        },
                        {
                            name:"天津市",
                            city:[
                                {
                                    name:"天津市",
                                    districtAndCounty:["和平区","河东区","河西区","南开区","河北区","红桥区","塘沽区","汉沽区","大港区","东丽区","西青区","津南区","北辰区","武清区","宝坻区","蓟县","宁河县","芦台镇","静海县","静海镇"]
                                }
                            ]
                        },
                        {
                            name:"上海市",
                            city:[
                                {
                                    name:"上海市",
                                    districtAndCounty:["黄浦区","卢湾区","徐汇区","长宁区","静安区","普陀区","闸北区","虹口区","杨浦区","闵行区","宝山区?","嘉定区","浦东新区","金山区","松江区","青浦区","南汇区","奉贤区","崇明县","城桥镇"]
                                }
                            ]
                        },
                        {
                            name:"重庆市",
                            city:[
                                {
                                    name:"重庆市",
                                    districtAndCounty:["渝中区","大渡口区","江北区","沙坪坝区","九龙坡区","南岸区","北碚区","万盛区","双桥区","渝北区","巴南区","万州区","涪陵区","黔江区","长寿区","合川市","永川区市","江津市","南川市","綦江县","潼南县","铜梁县","大足县","荣昌县","璧山县","垫江县","武隆县","丰都县","城口县","梁平县","开县","巫溪县","巫山县","奉节县","云阳县","忠县","石柱土家族自治县","彭水苗族土家族自治县","酉阳土家族苗族自治县","秀山土家族苗族自治县"]
                                }
                            ]
                        },
                        {
                            name:"河北省",
                            city:[
                                {
                                    name:"石家庄市",
                                    districtAndCounty:["长安区","桥东区","桥西区","新华区","裕华区","井陉矿区","辛集市","藁城市","晋州市","新乐市","鹿泉市","井陉县","微水镇","正定县","正定镇","栾城县","栾城镇","行唐县","龙州镇","灵寿县","灵寿镇","高邑县","高邑镇","深泽县","深泽镇","赞皇县","赞皇镇","无极县","无极镇","平山县","平山镇","元氏县","槐阳镇","赵县","赵州镇"]
                                },
                                {
                                    name:"张家口市",
                                    districtAndCounty:["桥西区","桥东区","宣化区","下花园区","宣化县","张家口市宣化区","张北县","张北镇","康保县","康保镇","沽源县","平定堡镇","尚义县","南壕堑镇","蔚县","蔚州镇","阳原县","西城镇","怀安县","柴沟堡镇","万全县","孔家庄镇","怀来县","沙城镇","涿鹿县","涿鹿镇","赤城县","赤城镇","崇礼县","西湾子镇"]
                                },
                                {
                                    name:"承德市",
                                    districtAndCounty:["双桥区","双滦区","鹰手营子矿区","承德县","下板城镇","兴隆县","兴隆镇","平泉县","平泉镇","滦平县","滦平镇","隆化县","隆化镇","丰宁满族自治县","大阁镇","宽城满族自治县","宽城镇","围场满族蒙古族自治县","围场镇"]
                                },
                                {
                                    name:"秦皇岛市",
                                    districtAndCounty:["海港区","山海关区","北戴河区","昌黎县","昌黎镇","抚宁县","抚宁镇","卢龙县","卢龙镇","青龙满族自治县","青龙镇"]
                                },
                                {
                                    name:"唐山市",
                                    districtAndCounty:["路北区","路南区","古冶区","开平区","丰润区","丰南区","遵化市","迁安市","滦县","滦州镇","滦南县","倴城镇","乐亭县","乐亭镇","迁西县","兴城镇","玉田县","玉田镇","唐海县","唐海镇"]
                                },
                                {
                                    name:"廊坊市",
                                    districtAndCounty:["安次区","广阳区","霸州市","三河市","固安县","固安镇","永清县","永清镇","香河县","淑阳镇","大城县","平舒镇","文安县","文安镇","大厂回族自治县","大厂镇"]
                                },
                                {
                                    name:"保定市",
                                    districtAndCounty:["新市区","北市区","南市区","定州市","涿州市","安国市","高碑店市","满城县","满城镇","清苑县","清苑镇","易县","易州镇","徐水县","安肃镇","涞源县","涞源镇","定兴县","定兴镇","顺平县","蒲阳镇","唐县","仁厚镇","望都县","望都镇","涞水县","涞水镇","高阳县","高阳镇","安新县","安新镇","雄县","雄州镇","容城县","容城镇","曲阳县","恒州镇","阜平县","阜平镇","博野县","博陵镇","蠡县","蠡吾镇"]
                                },
                                {
                                    name:"衡水市",
                                    districtAndCounty:["桃城区","冀州市","深州市","枣强县","枣强镇","武邑县","武邑镇","武强县","武强镇","饶阳县","饶阳镇","安平县","安平镇","故城县","郑口镇","景县","景州镇","阜城县","阜城镇"]
                                },
                                {
                                    name:"沧州市",
                                    districtAndCounty:["运河区","新华区","泊头市","任丘市","黄骅市","河间市","沧县","沧州市新华区","青县","清州镇","东光县","东光镇","海兴县","苏基镇","盐山县","盐山镇","肃宁县","肃宁镇","南皮县","南皮镇","吴桥县","桑园镇","献县","乐寿镇","孟村回族自治县","孟村镇"]
                                },
                                {
                                    name:"邢台市",
                                    districtAndCounty:["桥东区","桥西区","南宫市","沙河市","邢台县","邢台市桥东区","临城县","临城镇","内丘县","内丘镇","柏乡县","柏乡镇","隆尧县","隆尧镇","任县","任城镇","南和县","和阳镇","宁晋县","凤凰镇","巨鹿县","巨鹿镇","新河县","新河镇","广宗县","广宗镇","平乡县","丰州镇","威县","洺州镇","清河县","葛仙庄镇","临西县","临西镇"]
                                },
                                {
                                    name:"邯郸市",
                                    districtAndCounty:["丛台区","邯山区","复兴区","峰峰矿区","武安市","邯郸县","南堡乡东小屯村","临漳县","临漳镇","成安县","成安镇","大名县","大名镇","涉县","涉城镇","磁县","磁州镇","肥乡县","肥乡镇","永年县","临洺关镇","邱县","新马头镇","鸡泽县","鸡泽镇","广平县","广平镇","馆陶县","馆陶镇","魏县","魏城镇","曲周县","曲周镇"]
                                }
                            ]
                        },
                        {
                            name:"山西省",
                            city:[
                                {
                                    name:"太原市",
                                    districtAndCounty:["杏花岭区","小店区","迎泽区","尖草坪区","万柏林区","晋源区","古交市","清徐县","清源镇","阳曲县","黄寨镇","娄烦县","娄烦镇"]
                                },
                                {
                                    name:"朔州市",
                                    districtAndCounty:["朔城区","平鲁区","山阴县","岱岳乡","应县","金城镇","右玉县","新城镇","怀仁县","云中镇"]
                                },
                                {
                                    name:"大同市",
                                    districtAndCounty:["城区","矿区","南郊区","新荣区","阳高县","龙泉镇","天镇县","玉泉镇","广灵县","壶泉镇","灵丘县","武灵镇","浑源县","永安镇","左云县","云兴镇","大同县","西坪镇"]
                                },
                                {
                                    name:"阳泉市",
                                    districtAndCounty:["城区","矿区","郊区","平定县","冠山镇","盂县","秀水镇"]
                                },
                                {
                                    name:"长治市",
                                    districtAndCounty:["城区","郊区","潞城市","长治县","韩店镇","襄垣县","古韩镇","屯留县","麟绛镇","平顺县","青羊镇","黎城县","黎侯镇","壶关县","龙泉镇","长子县","丹朱镇","武乡县","丰州镇","沁县","定昌镇","沁源县","沁河镇"]
                                },
                                {
                                    name:"晋城市",
                                    districtAndCounty:["城区","高平市","泽州县","南村镇","沁水县","龙港镇","阳城县","凤城镇","陵川县","崇文镇"]
                                },
                                {
                                    name:"忻州市",
                                    districtAndCounty:["忻府区","原平市","定襄县","晋昌镇","五台县","台城镇","代县","上馆镇","繁峙县","繁城镇","宁武县","凤凰镇","静乐县","鹅城镇","神池县","龙泉镇","五寨县","砚城镇","岢岚县","岚漪镇","河曲县","文笔镇","保德县","东关镇","偏关县","新关镇"]
                                },
                                {
                                    name:"晋中市",
                                    districtAndCounty:["榆次区","介休市","榆社县","箕城镇","左权县","辽阳镇","和顺县","义兴镇","昔阳县","乐平镇","寿阳县","朝阳镇","太谷县","明星镇","祁县","昭余镇","平遥县","古陶镇","灵石县","翠峰镇"]
                                },
                                {
                                    name:"临汾市",
                                    districtAndCounty:["尧都区","侯马市","霍州市","曲沃县","乐昌镇","翼城县","唐兴镇","襄汾县","新城镇","洪洞县","大槐树镇","古县","岳阳镇","安泽县","府城镇","浮山县","天坛镇","吉县","吉昌镇","乡宁县","昌宁镇","蒲县","蒲城镇","大宁县","昕水镇","永和县","芝河镇","隰县","龙泉镇","汾西县","永安镇"]
                                },
                                {
                                    name:"吕梁市",
                                    districtAndCounty:["离石区","孝义市","汾阳市","文水县","凤城镇","中阳县","宁乡镇","兴县","蔚汾镇","临县","临泉镇","方山县","圪洞镇","柳林县","柳林镇","岚县","东村镇","交口县","水头镇","交城县","天宁镇","石楼县","灵泉镇"]
                                },
                                {
                                    name:"运城市",
                                    districtAndCounty:["盐湖区","永济市","河津市","芮城县","古魏镇","临猗县","猗氏镇","万荣县","解店镇","新绛县","龙兴镇","稷山县","稷峰镇","闻喜县","桐城镇","夏县","瑶峰镇","绛县","古绛镇","平陆县","圣人涧镇","垣曲县","新城镇"]
                                }
                            ]
                        },
                        {
                            name:"内蒙古",
                            city:[
                                {
                                    name:"呼和浩特市",
                                    districtAndCounty:["回民区","新城区","玉泉区","赛罕区","托克托县","双河镇","武川县","可可以力更镇","和林格尔县","城关镇","清水河县","城关镇","土默特左旗","察素齐镇"]
                                },
                                {
                                    name:"包头市",
                                    districtAndCounty:["昆都仑区","东河区","青山区","石拐区","白云矿区","九原区","固阳县","金山镇","土默特右旗","萨拉齐镇","达尔罕茂明安联合旗","百灵庙镇"]
                                },
                                {
                                    name:"乌海市",
                                    districtAndCounty:["海勃湾区","海南区","乌达区"]
                                },
                                {
                                    name:"赤峰市",
                                    districtAndCounty:["红山区","元宝山区","松山区","宁城县","天义镇","林西县","林西镇","阿鲁科尔沁旗","天山镇","巴林左旗","林东镇","巴林右旗","大板镇","克什克腾旗","经棚镇","翁牛特旗","乌丹镇","喀喇沁旗","锦山镇","敖汉旗","新惠镇"]
                                },
                                {
                                    name:"通辽市",
                                    districtAndCounty:["科尔沁区","霍林郭勒市","开鲁县","开鲁镇","库伦旗","库伦镇","奈曼旗","大沁他拉镇","扎鲁特旗","鲁北镇","科尔沁左翼中旗","保康镇","科尔沁左翼后旗","甘旗卡镇"]
                                },
                                {
                                    name:"呼伦贝尔市",
                                    districtAndCounty:["海拉尔区","满洲里市","扎兰屯市","牙克石市","根河市","额尔古纳市","阿荣旗","那吉镇","新巴尔虎右旗","阿拉坦额莫勒镇","新巴尔虎左旗","阿穆古郎镇","陈巴尔虎旗","巴彦库仁镇","鄂伦春自治旗","阿里河镇","鄂温克族自治旗","巴彦托海镇","莫力达瓦达斡尔族自治旗","尼尔基镇"]
                                },
                                {
                                    name:"鄂尔多斯市",
                                    districtAndCounty:["东胜区","达拉特旗","树林召镇","准格尔旗","薛家湾镇","鄂托克前旗","敖勒召其镇","鄂托克旗","乌兰镇","杭锦旗","锡尼镇","乌审旗","嘎鲁图镇","伊金霍洛旗","阿勒腾席热镇"]
                                },
                                {
                                    name:"乌兰察布市",
                                    districtAndCounty:["集宁区","丰镇市","卓资县","卓资山镇","化德县","长顺镇","商都县","商都镇","兴和县","城关镇","凉城县","岱海镇","察哈尔右翼前旗","土贵乌拉镇","察哈尔右翼中旗","科布尔镇","察哈尔右翼后旗","白音察干镇","四子王旗","乌兰花镇"]
                                },
                                {
                                    name:"巴彦淖尔市",
                                    districtAndCounty:["临河区","五原县","隆兴昌镇","磴口县","巴彦高勒镇","乌拉特前旗","乌拉山镇","乌拉特中旗","海流图镇","乌拉特后旗","巴音宝力格镇","杭锦后旗","陕坝镇"]
                                },
                                {
                                    name:"兴安盟",
                                    districtAndCounty:["乌兰浩特市","阿尔山市","突泉县","突泉镇","科尔沁右翼前旗","大坝沟镇","科尔沁右翼中旗","巴彦呼硕镇","扎赉特旗","音德尔镇"]
                                },
                                {
                                    name:"锡林郭勒盟",
                                    districtAndCounty:["锡林浩特市","二连浩特市","多伦县","多伦淖尔镇","阿巴嘎旗","别力古台镇","苏尼特左旗","满都拉图镇","苏尼特右旗","赛汉塔拉镇","东乌珠穆沁旗","乌里雅斯太镇","西乌珠穆沁旗","巴拉嘎尔郭勒镇","太仆寺旗","宝昌镇","镶黄旗","新宝拉格镇","正镶白旗","明安图镇","正蓝旗","上都镇"]
                                },
                                {
                                    name:"阿拉善盟",
                                    districtAndCounty:["巴彦浩特镇","阿拉善右旗","额肯呼都格镇","额济纳旗","达来呼布镇"]
                                }
                            ]
                        },
                        {
                            name:"辽宁省",
                            city:[
                                {
                                    name:"沈阳市",
                                    districtAndCounty:["沈河区","和平区","大东区","皇姑区","铁西区","苏家屯区","东陵区","新城子区","于洪区","新民市","辽中县","辽中镇","康平县","康平镇","法库县","法库镇"]
                                },
                                {
                                    name:"朝阳市",
                                    districtAndCounty:["双塔区","龙城区","北票市","凌源市","朝阳县","朝阳市双塔区","建平县","喀喇沁左翼蒙古族自治县","大城子镇"]
                                },
                                {
                                    name:"阜新市",
                                    districtAndCounty:["海州区","新邱区","太平区","清河门区","细河区","彰武县","彰武镇","阜新蒙古族自治县","阜新镇"]
                                },
                                {
                                    name:"铁岭市",
                                    districtAndCounty:["银州区","清河区","调兵山市","开原市","铁岭县","铁岭市银州区","西丰县","西丰镇","昌图县","昌图镇"]
                                },
                                {
                                    name:"抚顺市",
                                    districtAndCounty:["顺城区","新抚区","东洲区","望花区","抚顺县","抚顺市顺城区","新宾满族自治县","新宾镇","清原满族自治县","清原镇"]
                                },
                                {
                                    name:"本溪市",
                                    districtAndCounty:["平山区","溪湖区","明山区","南芬区","本溪满族自治县","小市镇","桓仁满族自治县","桓仁镇"]
                                },
                                {
                                    name:"辽阳市",
                                    districtAndCounty:["白塔区","文圣区","宏伟区","弓长岭区","太子河区","灯塔市","辽阳县","首山镇"]
                                },
                                {
                                    name:"鞍山市",
                                    districtAndCounty:["铁东区","铁西区","立山区","千山区","海城市","台安县","台安镇","岫岩满族自治县","岫岩镇"]
                                },
                                {
                                    name:"丹东市",
                                    districtAndCounty:["振兴区","元宝区","振安区","凤城市","东港市","宽甸满族自治县","宽甸镇"]
                                },
                                {
                                    name:"大连市",
                                    districtAndCounty:["西岗区","中山区","沙河口区","甘井子区","旅顺口区","金州区","瓦房店市","普兰店市","庄河市","长海县","大长山岛镇"]
                                },
                                {
                                    name:"营口市",
                                    districtAndCounty:["站前区","西市区","鲅鱼圈区","老边区","大石桥市","盖州市"]
                                },
                                {
                                    name:"盘锦市",
                                    districtAndCounty:["兴隆台区","双台子区","大洼县","大洼镇","盘山县","盘锦市双台子区"]
                                },
                                {
                                    name:"锦州市",
                                    districtAndCounty:["太和区","古塔区","凌河区","凌海市","北宁市","黑山县","黑山镇","义县","义州镇"]
                                },
                                {
                                    name:"葫芦岛市",
                                    districtAndCounty:["龙港区","连山区","南票区","兴城市","绥中县","绥中镇","建昌县","建昌镇"]
                                }
                            ]
                        },
                        {
                            name:"吉林省",
                            city:[
                                {
                                    name:"长春市",
                                    districtAndCounty:["朝阳区","南关区","宽城区","二道区","绿园区","双阳区","德惠市","九台市","榆树市","农安县","农安镇"]
                                },
                                {
                                    name:"白城市",
                                    districtAndCounty:["洮北区","大安市","洮南市","镇赉县","镇赉镇","通榆县","开通镇"]
                                },
                                {
                                    name:"松原市",
                                    districtAndCounty:["宁江区","扶余县","三岔河镇","长岭县","长岭镇","乾安县","乾安镇","前郭尔罗斯蒙古族自治县","前郭镇"]
                                },
                                {
                                    name:"吉林市",
                                    districtAndCounty:["船营区","龙潭区","昌邑区","丰满区","磐石市","蛟河市","桦甸市","舒兰市","永吉县","口前镇"]
                                },
                                {
                                    name:"四平市",
                                    districtAndCounty:["铁西区","铁东区","双辽市","公主岭市","梨树县","梨树镇","伊通满族自治县","伊通镇"]
                                },
                                {
                                    name:"辽源市",
                                    districtAndCounty:["龙山区","西安区","东丰县","东丰镇","东辽县","白泉镇"]
                                },
                                {
                                    name:"通化市",
                                    districtAndCounty:["东昌区","二道江区","梅河口市","集安市","通化县","快大茂镇","辉南县","朝阳镇","柳河县","柳河镇"]
                                },
                                {
                                    name:"白山市",
                                    districtAndCounty:["八道江区","临江市","江源县","孙家堡子镇","抚松县","抚松镇","靖宇县","靖宇镇","长白朝鲜族自治县","长白镇"]
                                },
                                {
                                    name:"延边州",
                                    districtAndCounty:["延吉市","图们市","敦化市","珲春市","龙井市","和龙市","汪清县","汪清镇","安图县","明月镇"]
                                }
                            ]
                        },
                        {
                            name:"黑龙江省",
                            city:[
                                {
                                    name:"哈尔滨市",
                                    districtAndCounty:["松北区","道里区","南岗区","道外区","香坊区","动力区","平房区","呼兰区","双城市","尚志市","五常市","阿城市","依兰县","依兰镇","方正县","方正镇","宾县","宾州镇","巴彦县","巴彦镇","木兰县","木兰镇","通河县","通河镇","延寿县","延寿镇"]
                                },
                                {
                                    name:"齐齐哈尔市",
                                    districtAndCounty:["建华区","龙沙区","铁锋区","昂昂溪区","富拉尔基区","碾子山区","梅里斯达斡尔族区","讷河市","龙江县","龙江镇","依安县","依安镇","泰来县","泰来镇","甘南县","甘南镇","富裕县","富裕镇","克山县","克山镇","克东县","克东镇","拜泉县","拜泉镇"]
                                },
                                {
                                    name:"七台河市",
                                    districtAndCounty:["桃山区","新兴区","茄子河区","勃利县","勃利镇"]
                                },
                                {
                                    name:"黑河市",
                                    districtAndCounty:["爱辉区","北安市","五大连池市","嫩江县","嫩江镇","逊克县","边疆镇","孙吴县","孙吴镇"]
                                },
                                {
                                    name:"大庆市",
                                    districtAndCounty:["萨尔图区","龙凤区","让胡路区","大同区","红岗区","肇州县","肇州镇","肇源县","肇源镇","林甸县","林甸镇","杜尔伯特蒙古族自治县","泰康镇"]
                                },
                                {
                                    name:"鹤岗市",
                                    districtAndCounty:["兴山区","向阳区","工农区","南山区","兴安区","东山区","萝北县","凤翔镇","绥滨县","绥滨镇"]
                                },
                                {
                                    name:"伊春市",
                                    districtAndCounty:["伊春区","南岔区","友好区","西林区","翠峦区","新青区","美溪区","金山屯区","五营区","乌马河区","汤旺河区","带岭区","乌伊岭区","红星区","上甘岭区","铁力市","嘉荫县","朝阳镇"]
                                },
                                {
                                    name:"佳木斯市",
                                    districtAndCounty:["前进区","永红区","向阳区","东风区","郊区","同江市","富锦市","桦南县","桦南镇","桦川县","悦来镇","汤原县","汤原镇","抚远县","抚远镇"]
                                },
                                {
                                    name:"双鸭山市",
                                    districtAndCounty:["尖山区","岭东区","四方台区","宝山区","集贤县","福利镇","友谊县","友谊镇","宝清县","宝清镇","饶河县","饶河镇"]
                                },
                                {
                                    name:"鸡西市",
                                    districtAndCounty:["鸡冠区","恒山区","滴道区","梨树区","城子河区","麻山区","虎林市","密山市","鸡东县","鸡东镇"]
                                },
                                {
                                    name:"牡丹江市",
                                    districtAndCounty:["爱民区","东安区","阳明区","西安区","穆棱市","绥芬河市","海林市","宁安市","东宁县","东宁镇","林口县","林口镇"]
                                },
                                {
                                    name:"绥化市",
                                    districtAndCounty:["北林区","安达市","肇东市","海伦市","望奎县","望奎镇","兰西县","兰西镇","青冈县","青冈镇","庆安县","庆安镇","明水县","明水镇","绥棱县","绥棱镇"]
                                },
                                {
                                    name:"大兴安岭地区",
                                    districtAndCounty:["呼玛县","呼玛镇","塔河县","塔河镇","漠河县","西林吉镇"]
                                }
                            ]
                        },
                        {
                            name:"江苏省",
                            city:[
                                {
                                    name:"南京市",
                                    districtAndCounty:["玄武区","白下区","秦淮区","建邺区","鼓楼区","下关区","浦口区","六合区","栖霞区","雨花台区","江宁区","溧水县","永阳镇","高淳县","淳溪镇"]
                                },
                                {
                                    name:"徐州市",
                                    districtAndCounty:["云龙区","鼓楼区","九里区","贾汪区","泉山区","邳州市","新沂市","铜山县","铜山镇","睢宁县","睢城镇","沛县","沛城镇","丰县","凤城镇"]
                                },
                                {
                                    name:"连云港市",
                                    districtAndCounty:["新浦区","连云区","海州区","赣榆县","青口镇","灌云县","伊山镇","东海县","牛山镇","灌南县","新安镇"]
                                },
                                {
                                    name:"宿迁市",
                                    districtAndCounty:["宿城区","宿豫区","沭阳县","沭城镇","泗阳县","众兴镇","泗洪县","青阳镇"]
                                },
                                {
                                    name:"淮安市",
                                    districtAndCounty:["清河区","清浦区","楚州区","淮阴区","金湖县","黎城镇","盱眙县","盱城镇","洪泽县","高良涧镇","涟水县","涟城镇"]
                                },
                                {
                                    name:"盐城市",
                                    districtAndCounty:["亭湖区","盐都区","东台市","大丰市","射阳县","合德镇","阜宁县","阜城镇","滨海县","东坎镇","响水县","响水镇","建湖县","近湖镇"]
                                },
                                {
                                    name:"扬州市",
                                    districtAndCounty:["维扬区","广陵区","邗江区","仪征市","江都市","高邮市","宝应县","安宜镇"]
                                },
                                {
                                    name:"泰州市",
                                    districtAndCounty:["海陵区","高港区","靖江市","泰兴市","姜堰市","兴化市"]
                                },
                                {
                                    name:"南通市",
                                    districtAndCounty:["崇川区","港闸区","海门市","启东市","通州市","如皋市","如东县","掘港镇","海安县","海安镇"]
                                },
                                {
                                    name:"镇江市",
                                    districtAndCounty:["京口区","润州区","丹徒区","扬中市","丹阳市","句容市"]
                                },
                                {
                                    name:"常州市",
                                    districtAndCounty:["钟楼区","天宁区","戚墅堰区","新北区","武进区","金坛市","溧阳市"]
                                },
                                {
                                    name:"无锡市",
                                    districtAndCounty:["崇安区","南长区","北塘区","滨湖区","惠山区","锡山区","江阴市","宜兴市"]
                                },
                                {
                                    name:"苏州市",
                                    districtAndCounty:["金阊区","沧浪区","平江区","虎丘区","吴中区","相城区","吴江市","昆山市","太仓市","常熟市","张家港市"]
                                }
                            ]
                        },
                        {
                            name:"浙江省",
                            city:[
                                {
                                    name:"杭州市",
                                    districtAndCounty:["拱墅区","上城区","下城区","江干区","西湖区","滨江区","余杭区","萧山区","临安市","富阳市","建德市","桐庐县","淳安县","千岛湖镇"]
                                },
                                {
                                    name:"湖州市",
                                    districtAndCounty:["吴兴区","南浔区","长兴县","雉城镇","德清县","武康镇","安吉县","递铺镇"]
                                },
                                {
                                    name:"嘉兴市",
                                    districtAndCounty:["南湖区","秀洲区","平湖市","海宁市","桐乡市","嘉善县","魏塘镇","海盐县","武原镇"]
                                },
                                {
                                    name:"舟山市",
                                    districtAndCounty:["定海区","普陀区","岱山县","高亭镇","嵊泗县","菜园镇"]
                                },
                                {
                                    name:"宁波市",
                                    districtAndCounty:["海曙区","江东区","江北区","北仑区","镇海区","鄞州区","慈溪市","余姚市","奉化市","宁海县","象山县"]
                                },
                                {
                                    name:"绍兴市",
                                    districtAndCounty:["越城区","诸暨市","上虞市","嵊州市","绍兴县","新昌县","城关镇"]
                                },
                                {
                                    name:"衢州市",
                                    districtAndCounty:["柯城区","衢江区","江山市","常山县","天马镇","开化县","城关镇","龙游县"]
                                },
                                {
                                    name:"金华市",
                                    districtAndCounty:["婺城区","金东区","兰溪市","永康市","义乌市","东阳市","武义县","浦江县","磐安县","安文镇"]
                                },
                                {
                                    name:"台州市",
                                    districtAndCounty:["椒江区","黄岩区","路桥区","临海市","温岭市","三门县","海游镇","天台县","仙居县","玉环县","珠港镇"]
                                },
                                {
                                    name:"温州市",
                                    districtAndCounty:["鹿城区","龙湾区","瓯海区","瑞安市","乐清市","永嘉县","上塘镇","文成县","大峃镇","平阳县","昆阳镇","泰顺县","罗阳镇","洞头县","北岙镇","苍南县","灵溪镇"]
                                },
                                {
                                    name:"丽水市",
                                    districtAndCounty:["莲都区","龙泉市","缙云县","五云镇","青田县","鹤城镇","云和县","云和镇","遂昌县","妙高镇","松阳县","西屏镇","庆元县","松源镇","景宁畲族自治县","鹤溪镇"]
                                }
                            ]
                        },
                        {
                            name:"安徽省",
                            city:[
                                {
                                    name:"合肥市",
                                    districtAndCounty:["庐阳区","瑶海区","蜀山区","包河区","长丰县","水湖镇","肥东县","店埠镇","肥西县","上派镇"]
                                },
                                {
                                    name:"宿州市",
                                    districtAndCounty:["埇桥区","砀山县","砀城镇","萧县","龙城镇","灵璧县","灵城镇","泗县","泗城镇"]
                                },
                                {
                                    name:"淮北市",
                                    districtAndCounty:["相山区","杜集区","烈山区","濉溪县","濉溪镇"]
                                },
                                {
                                    name:"亳州市",
                                    districtAndCounty:["谯城区","涡阳县","城关镇","蒙城县","城关镇","利辛县","城关镇"]
                                },
                                {
                                    name:"阜阳市",
                                    districtAndCounty:["颍州区","颍东区","颍泉区","界首市","临泉县","城关镇","太和县","城关镇","阜南县","城关镇","颍上县","慎城镇"]
                                },
                                {
                                    name:"蚌埠市",
                                    districtAndCounty:["蚌山区","龙子湖区","禹会区","淮上区","怀远县","城关镇","五河县","城关镇","固镇县","城关镇"]
                                },
                                {
                                    name:"淮南市",
                                    districtAndCounty:["田家庵区","大通区","谢家集区","八公山区","潘集区","凤台县","城关镇"]
                                },
                                {
                                    name:"滁州市",
                                    districtAndCounty:["琅区","南谯区","明光市","天长市","来安县","新安镇","全椒县","襄河镇","定远县","定城镇","凤阳县","府城镇"]
                                },
                                {
                                    name:"马鞍山市",
                                    districtAndCounty:["雨山区","花山区","金家庄区","当涂县","姑孰镇"]
                                },
                                {
                                    name:"芜湖市",
                                    districtAndCounty:["镜湖区","弋江区","三山区","鸠江区","芜湖县","湾镇","繁昌县","繁阳镇","南陵县","籍山镇"]
                                },
                                {
                                    name:"铜陵市",
                                    districtAndCounty:["铜官山区","狮子山区","郊区","铜陵县","五松镇"]
                                },
                                {
                                    name:"安庆市",
                                    districtAndCounty:["迎江区","大观区","宜秀区","桐城市","怀宁县","高河镇","枞阳县","枞阳镇","潜山县","梅城镇","太湖县","晋熙镇","宿松县","孚玉镇","望江县","雷阳镇","岳西县","天堂镇"]
                                },
                                {
                                    name:"黄山市",
                                    districtAndCounty:["屯溪区","黄山区","徽州区","歙县","徽城镇","休宁县","海阳镇","黟县","碧阳镇","祁门县","祁山镇"]
                                },
                                {
                                    name:"六安市",
                                    districtAndCounty:["金安区","裕安区","寿县","寿春镇","霍邱县","城关镇","舒城县","城关镇","金寨县","梅山镇","霍山县","衡山镇"]
                                },
                                {
                                    name:"巢湖市",
                                    districtAndCounty:["居巢区","庐江县","庐城镇","无为县","无城镇","含山县","环峰镇","和县","历阳镇"]
                                },
                                {
                                    name:"池州市",
                                    districtAndCounty:["贵池区","东至县","尧渡镇","石台县","七里镇","青阳县","蓉城镇"]
                                },
                                {
                                    name:"宣城市",
                                    districtAndCounty:["宣州区","宁国市","郎溪县","建平镇","广德县","桃州镇","泾县","泾川镇","旌德县","旌阳镇","绩溪县","华阳镇"]
                                }
                            ]
                        },
                        {
                            name:"福建省",
                            city:[
                                {
                                    name:"福州市",
                                    districtAndCounty:["鼓楼区","台江区","仓山区","马尾区","晋安区","福清市","长乐市","闽侯县","连江县","凤城镇","罗源县","凤山镇","闽清县","梅城镇","永泰县","樟城镇","平潭县","潭城镇"]
                                },
                                {
                                    name:"南平市",
                                    districtAndCounty:["延平区","邵武市","武夷山市","建瓯市","建阳市","顺昌县","浦城县","光泽县","杭川镇","松溪县","松源镇","政和县","熊山镇"]
                                },
                                {
                                    name:"莆田市",
                                    districtAndCounty:["城厢区","涵江区","荔城区","秀屿区","仙游县"]
                                },
                                {
                                    name:"三明市",
                                    districtAndCounty:["梅列区","三元区","永安市","明溪县","雪峰镇","清流县","龙津镇","宁化县","翠江镇","大田县","均溪镇","尤溪县","城关镇","沙县","将乐县","古镛镇","泰宁县","杉城镇","建宁县","濉城镇"]
                                },
                                {
                                    name:"泉州市",
                                    districtAndCounty:["鲤城区","丰泽区","洛江区","泉港区","石狮市","晋江市","南安市","惠安县","螺城镇","安溪县","凤城镇","永春县","桃城镇","德化县","浔中镇","金门县","☆"]
                                },
                                {
                                    name:"厦门市",
                                    districtAndCounty:["思明区","海沧区","湖里区","集美区","同安区","翔安区"]
                                },
                                {
                                    name:"漳州市",
                                    districtAndCounty:["芗城区","龙文区","龙海市","云霄县","云陵镇","漳浦县","绥安镇","诏安县","南诏镇","长泰县","武安镇","东山县","西埔镇","南靖县","山城镇","平和县","小溪镇","华安县","华丰镇"]
                                },
                                {
                                    name:"龙岩市",
                                    districtAndCounty:["新罗区","漳平市","长汀县","汀州镇","永定县","凤城镇","上杭县","临江镇","武平县","平川镇","连城县","莲峰镇"]
                                },
                                {
                                    name:"宁德市",
                                    districtAndCounty:["蕉城区","福安市","福鼎市","寿宁县","鳌阳镇","霞浦县","柘荣县","双城镇","屏南县","古峰镇","古田县","周宁县","狮城镇"]
                                }
                            ]
                        },
                        {
                            name:"江西省",
                            city:[
                                {
                                    name:"南昌市",
                                    districtAndCounty:["东湖区","西湖区","青云谱区","湾里区","青山湖区","南昌县","莲塘镇","新建县","长堎镇","安义县","龙津镇","进贤县","民和镇"]
                                },
                                {
                                    name:"九江市",
                                    districtAndCounty:["浔阳区","庐山区","瑞昌市","九江县","沙河街镇","武宁县","新宁镇","修水县","义宁镇","永修县","涂埠镇","德安县","蒲亭镇","星子县","南康镇","都昌县","都昌镇","湖口县","双钟镇","彭泽县","龙城镇"]
                                },
                                {
                                    name:"景德镇市",
                                    districtAndCounty:["珠山区","昌江区","乐平市","浮梁县","浮梁镇"]
                                },
                                {
                                    name:"鹰潭市",
                                    districtAndCounty:["月湖区","贵溪市","余江县","邓埠镇"]
                                },
                                {
                                    name:"新余市",
                                    districtAndCounty:["渝水区","分宜县","分宜镇"]
                                },
                                {
                                    name:"萍乡市",
                                    districtAndCounty:["安源区","湘东区","莲花县","琴亭镇","上栗县","上栗镇","芦溪县","芦溪镇"]
                                },
                                {
                                    name:"赣州市",
                                    districtAndCounty:["章贡区","瑞金市","南康市","赣县","梅林镇","信丰县","嘉定镇","大余县","南安镇","上犹县","东山镇","崇义县","横水镇","安远县","欣山镇","龙南县","龙南镇","定南县","历市镇","全南县","城厢镇","宁都县","梅江镇","于都县","贡江镇","兴国县","潋江镇","会昌县","文武坝镇","寻乌县","长宁镇","石城县","琴江镇"]
                                },
                                {
                                    name:"上饶市",
                                    districtAndCounty:["信州区","德兴市","上饶县","旭日镇","广丰县","永丰镇","玉山县","冰溪镇","铅山县","河口镇","横峰县","岑阳镇","弋阳县","弋江镇","余干县","玉亭镇","鄱阳县","鄱阳镇","万年县","陈营镇","婺源县","紫阳镇"]
                                },
                                {
                                    name:"抚州市",
                                    districtAndCounty:["临川区","南城县","建昌镇","黎川县","日峰镇","南丰县","琴城镇","崇仁县","巴山镇","乐安县","鳌溪镇","宜黄县","凤冈镇","金溪县","秀谷镇","资溪县","鹤城镇","东乡县","孝岗镇","广昌县","旴江镇"]
                                },
                                {
                                    name:"宜春市",
                                    districtAndCounty:["袁州区","丰城市","樟树市","高安市","奉新县","冯川镇","万载县","上高县","宜丰县","新昌镇","靖安县","双溪镇","铜鼓县","永宁镇"]
                                },
                                {
                                    name:"吉安市",
                                    districtAndCounty:["吉州区","青原区","井冈山市","厦坪镇","吉安县","敦厚镇","吉水县","文峰镇","峡江县","水边镇","新干县","金川镇","永丰县","恩江镇","泰和县","澄江镇","遂川县","泉江镇","万安县","芙蓉镇","安福县","平都镇","永新县","禾川镇"]
                                }
                            ]
                        },
                        {
                            name:"山东省",
                            city:[
                                {
                                    name:"济南市",
                                    districtAndCounty:["市中区","历下区","槐荫区","天桥区","历城区","长清区","章丘市","平阴县","平阴镇","济阳县","济阳镇","商河县"]
                                },
                                {
                                    name:"青岛市",
                                    districtAndCounty:["市南区","市北区","四方区","黄岛区","崂山区","城阳区","李沧区","胶州市","即墨市","平度市","胶南市","莱西市"]
                                },
                                {
                                    name:"聊城市",
                                    districtAndCounty:["东昌府区","临清市","阳谷县","莘县","茌平县","东阿县","冠县","冠城镇","高唐县"]
                                },
                                {
                                    name:"德州市",
                                    districtAndCounty:["德城区","乐陵市","禹城市","陵县","陵城镇","平原县","夏津县","夏津镇","武城县","武城镇","齐河县","晏城镇","临邑县","宁津县","宁津镇","庆云县","庆云镇"]
                                },
                                {
                                    name:"东营市",
                                    districtAndCounty:["东营区","河口区","垦利县","垦利镇","利津县","利津镇","广饶县","广饶镇"]
                                },
                                {
                                    name:"淄博市",
                                    districtAndCounty:["张店区","淄川区","博山区","临淄区","周村区","桓台县","索镇","高青县","田镇","沂源县","南麻镇"]
                                },
                                {
                                    name:"潍坊市",
                                    districtAndCounty:["潍城区","寒亭区","坊子区","奎文区","安丘市","昌邑市","高密市","青州市","诸城市","寿光市","临朐县","昌乐县"]
                                },
                                {
                                    name:"烟台市",
                                    districtAndCounty:["莱山区","芝罘区","福山区","牟平区","栖霞市","海阳市","龙口市","莱阳市","莱州市","蓬莱市","招远市","长岛县","南长山镇"]
                                },
                                {
                                    name:"威海市",
                                    districtAndCounty:["环翠区","荣成市","乳山市","文登市"]
                                },
                                {
                                    name:"日照市",
                                    districtAndCounty:["东港区","岚山区","五莲县","洪凝镇","莒县","城阳镇"]
                                },
                                {
                                    name:"临沂市",
                                    districtAndCounty:["兰山区","罗庄区","河东区","郯城县","郯城镇","苍山县","卞庄镇","莒南县","十字路镇","沂水县","沂水镇","蒙阴县","蒙阴镇","平邑县","平邑镇","费县","费城镇","沂南县","界湖镇","临沭县","临沭镇"]
                                },
                                {
                                    name:"枣庄市",
                                    districtAndCounty:["薛城区","市中区","峄城区","台儿庄区","山亭区","滕州市"]
                                },
                                {
                                    name:"济宁市",
                                    districtAndCounty:["市中区","任城区","曲阜市","兖州市","邹城市","微山县","鱼台县","谷亭镇","金乡县","金乡镇","嘉祥县","嘉祥镇","汶上县","汶上镇","泗水县","梁山县","梁山镇"]
                                },
                                {
                                    name:"泰安市",
                                    districtAndCounty:["泰山区","岱岳区","新泰市","肥城市","宁阳县","宁阳镇","东平县","东平镇"]
                                },
                                {
                                    name:"莱芜市",
                                    districtAndCounty:["莱城区","钢城区"]
                                },
                                {
                                    name:"滨州市",
                                    districtAndCounty:["滨城区","惠民县","惠民镇","阳信县","阳信镇","无棣县","无棣镇","沾化县","富国镇","博兴县","博兴镇","邹平县"]
                                },
                                {
                                    name:"菏泽市",
                                    districtAndCounty:["牡丹区","曹县","曹城镇","定陶县","定陶镇","成武县","成武镇","单县","单城镇","巨野县","巨野镇","郓城县","郓城镇","鄄城县","鄄城镇","东明县","城关镇"]
                                }
                            ]
                        },
                        {
                            name:"河南省",
                            city:[
                                {
                                    name:"郑州市",
                                    districtAndCounty:["中原区","二七区","管城回族区","金水区","上街区","惠济区","新郑市","登封市","新密市","巩义市","荥阳市","中牟县","城关镇"]
                                },
                                {
                                    name:"开封市",
                                    districtAndCounty:["鼓楼区","龙亭区","顺河回族区","禹王台区","金明区","杞县","城关镇","通许县","城关镇","尉氏县","城关镇","开封县","城关镇","兰考县","城关镇"]
                                },
                                {
                                    name:"三门峡市",
                                    districtAndCounty:["湖滨区","义马市","灵宝市","渑池县","城关镇","陕县","大营镇","卢氏县","城关镇"]
                                },
                                {
                                    name:"洛阳市",
                                    districtAndCounty:["西工区","老城区","瀍河回族区","涧西区","吉利区","洛龙区","偃师市","孟津县","城关镇","新安县","城关镇","栾川县","城关镇","嵩县","城关镇","汝阳县","城关镇","宜阳县","城关镇","洛宁县","城关镇","伊川县","城关镇"]
                                },
                                {
                                    name:"焦作市",
                                    districtAndCounty:["解放区","山阳区","中站区","马村区","孟州市","沁阳市","修武县","城关镇","博爱县","清化镇","武陟县","木城镇","温县","温泉镇"]
                                },
                                {
                                    name:"新乡市",
                                    districtAndCounty:["卫滨区","红旗区","凤泉区","牧野区","卫辉市","辉县市","新乡县","新乡市红旗区","获嘉县","城关镇","原阳县","城关镇","延津县","城关镇","封丘县","城关镇","长垣县","城关镇"]
                                },
                                {
                                    name:"鹤壁市",
                                    districtAndCounty:["淇滨区","山城区","鹤山区","浚县","城关镇","淇县","朝歌镇"]
                                },
                                {
                                    name:"安阳市",
                                    districtAndCounty:["北关区","文峰区","殷都区","龙安区","林州市","安阳县","安阳市北关区","汤阴县","城关镇","滑县","道口镇","内黄县","城关镇"]
                                },
                                {
                                    name:"濮阳市",
                                    districtAndCounty:["华龙区","清丰县","城关镇","南乐县","城关镇","范县","城关镇","台前县","城关镇","濮阳县","城关镇"]
                                },
                                {
                                    name:"商丘市",
                                    districtAndCounty:["梁园区","睢阳区","永城市","虞城县","城关镇","民权县","城关镇","宁陵县","城关镇","睢县","城关镇","夏邑县","城关镇","柘城县","城关镇"]
                                },
                                {
                                    name:"许昌市",
                                    districtAndCounty:["魏都区","禹州市","长葛市","许昌县","许昌市魏都区","鄢陵县","安陵镇","襄城县","城关镇"]
                                },
                                {
                                    name:"漯河市",
                                    districtAndCounty:["源汇区","郾城区","召陵区","舞阳县","舞泉镇","临颍县","城关镇"]
                                },
                                {
                                    name:"平顶山市",
                                    districtAndCounty:["新华区","卫东区","湛河区","石龙区","舞钢市","汝州市","宝丰县","城关镇","叶县","昆阳镇","鲁山县","鲁阳镇","郏县","城关镇"]
                                },
                                {
                                    name:"南阳市",
                                    districtAndCounty:["卧龙区","宛城区","邓州市","南召县","城关镇","方城县","城关镇","西峡县","镇平县","城关镇","内乡县","城关镇","淅川县","社旗县","赊店镇","唐河县","新野县","城关镇","桐柏县","城关镇"]
                                },
                                {
                                    name:"信阳市",
                                    districtAndCounty:["河区","平桥区","息县","城关镇","淮滨县","城关镇","潢川县","光山县","固始县","城关镇","商城县","城关镇","罗山县","城关镇","新县","新集镇"]
                                },
                                {
                                    name:"周口市",
                                    districtAndCounty:["川汇区","项城市","扶沟县","城关镇","西华县","城关镇","商水县","城关镇","太康县","城关镇","鹿邑县","城关镇","郸城县","城关镇","淮阳县","城关镇","沈丘县","槐店镇"]
                                },
                                {
                                    name:"驻马店市",
                                    districtAndCounty:["驿城区","确山县","盘龙镇","泌阳县","泌水镇","遂平县","灈阳镇","西平县","上蔡县","蔡都镇","汝南县","汝宁镇","平舆县","古槐镇","新蔡县","古吕镇","正阳县","真阳镇"]
                                },
                                {
                                    name:"济源市",
                                    districtAndCounty:[]
                                }
                            ]
                        },
                        {
                            name:"湖北省",
                            city:[
                                {
                                    name:"武汉市",
                                    districtAndCounty:["江岸区","江汉区","硚口区","汉阳区","武昌区","青山区","洪山区","东西湖区","汉南区","蔡甸区","江夏区","黄陂区","新洲区"]
                                },
                                {
                                    name:"十堰市",
                                    districtAndCounty:["张湾区","茅箭区","丹江口市","郧县","城关镇","竹山县","城关镇","房县","城关镇","郧西县","城关镇","竹溪县","城关镇"]
                                },
                                {
                                    name:"襄樊市",
                                    districtAndCounty:["襄城区","樊城区","襄阳区","老河口市","枣阳市","宜城市","南漳县","城关镇","谷城县","城关镇","保康县","城关镇"]
                                },
                                {
                                    name:"荆门市",
                                    districtAndCounty:["东宝区","掇刀区","钟祥市","沙洋县","沙洋镇","京山县","新市镇"]
                                },
                                {
                                    name:"孝感市",
                                    districtAndCounty:["孝南区","应城市","安陆市","汉川市","孝昌县","花园镇","大悟县","城关镇","云梦县","城关镇"]
                                },
                                {
                                    name:"黄冈市",
                                    districtAndCounty:["黄州区","麻城市","武穴市","红安县","城关镇","罗田县","凤山镇","英山县","温泉镇","浠水县","清泉镇","蕲春县","漕河镇","黄梅县","黄梅镇","团风县","团风镇"]
                                },
                                {
                                    name:"鄂州市",
                                    districtAndCounty:["鄂城区","梁子湖区","华容区"]
                                },
                                {
                                    name:"黄石市",
                                    districtAndCounty:["黄石港区","西塞山区","下陆区","铁山区","大冶市","阳新县","兴国镇"]
                                },
                                {
                                    name:"咸宁市",
                                    districtAndCounty:["咸安区","赤壁市","嘉鱼县","鱼岳镇","通城县","隽水镇","崇阳县","天城镇","通山县","通羊镇"]
                                },
                                {
                                    name:"荆州市",
                                    districtAndCounty:["沙市区","荆州区","石首市","洪湖市","松滋市","江陵县","郝穴镇","公安县","斗湖堤镇","监利县","容城镇"]
                                },
                                {
                                    name:"宜昌市",
                                    districtAndCounty:["西陵区","伍家岗区","点军区","猇亭区","夷陵区","枝江市","宜都市","当阳市","远安县","鸣凤镇","兴山县","古夫镇","秭归县","茅坪镇","长阳土家族自治县","龙舟坪镇","五峰土家族自治县","五峰镇"]
                                },
                                {
                                    name:"随州市",
                                    districtAndCounty:["曾都区","广水市"]
                                },
                                {
                                    name:"省直辖县级行政单位",
                                    districtAndCounty:["仙桃市","天门市","潜江市","神农架林区","松柏镇"]
                                },
                                {
                                    name:"恩施州",
                                    districtAndCounty:["恩施市","利川市","建始县","业州镇","巴东县","信陵镇","宣恩县","珠山镇","咸丰县","高乐山镇","来凤县","翔凤镇","鹤峰县","容美镇"]
                                }
                            ]
                        },
                        {
                            name:"湖南省",
                            city:[
                                {
                                    name:"长沙市",
                                    districtAndCounty:["长沙市","岳麓区","芙蓉区","天心区","开福区","雨花区","浏阳市","长沙县","星沙镇","望城县","高塘岭镇","宁乡县","玉潭镇"]
                                },
                                {
                                    name:"张家界市",
                                    districtAndCounty:["永定区","武陵源区","慈利县","零阳镇","桑植县","澧源镇"]
                                },
                                {
                                    name:"常德市",
                                    districtAndCounty:["武陵区","鼎城区","津市市","安乡县","城关镇","汉寿县","龙阳镇","澧县","澧阳镇","临澧县","安福镇","桃源县","漳江镇","石门县","楚江镇"]
                                },
                                {
                                    name:"益阳市",
                                    districtAndCounty:["赫山区","资阳区","沅江市","南县","南洲镇","桃江县","桃花江镇","安化县","东坪镇"]
                                },
                                {
                                    name:"岳阳市",
                                    districtAndCounty:["岳阳楼区","君山区","云溪区","汨罗市","临湘市","岳阳县","荣家湾镇","华容县","城关镇","湘阴县","文星镇","平江县","汉昌镇"]
                                },
                                {
                                    name:"株洲市",
                                    districtAndCounty:["天元区","荷塘区","芦淞区","石峰区","醴陵市","株洲县","渌口镇","攸县","城关镇","茶陵县","城关镇","炎陵县","霞阳镇"]
                                },
                                {
                                    name:"湘潭市",
                                    districtAndCounty:["岳塘区","雨湖区","湘乡市","韶山市","湘潭县","易俗河镇"]
                                },
                                {
                                    name:"衡阳市",
                                    districtAndCounty:["雁峰区","珠晖区","石鼓区","蒸湘区","南岳区","常宁市","耒阳市","衡阳县","西渡镇","衡南县","云集镇","衡山县","开云镇","衡东县","城关镇","祁东县","洪桥镇"]
                                },
                                {
                                    name:"郴州市",
                                    districtAndCounty:["北湖区","苏仙区","资兴市","桂阳县","城关镇","永兴县","城关镇","宜章县","城关镇","嘉禾县","城关镇","临武县","城关镇","汝城县","城关镇","桂东县","城关镇","安仁县","城关镇"]
                                },
                                {
                                    name:"永州市",
                                    districtAndCounty:["冷水滩区","零陵区","东安县","白牙市镇","道县","道江镇","宁远县","舜陵镇","江永县","潇浦镇","蓝山县","塔峰镇","新田县","龙泉镇","双牌县","泷泊镇","祁阳县","浯溪镇","江华瑶族自治县","沱江镇"]
                                },
                                {
                                    name:"邵阳市",
                                    districtAndCounty:["双清区","大祥区","北塔区","武冈市","邵东县","两市镇","邵阳县","塘渡口镇","新邵县","酿溪镇","隆回县","桃洪镇","洞口县","洞口镇","绥宁县","长铺镇","新宁县","金石镇","城步苗族自治县","儒林镇"]
                                },
                                {
                                    name:"怀化市",
                                    districtAndCounty:["鹤城区","洪江市","沅陵县","沅陵镇","辰溪县","辰阳镇","溆浦县","卢峰镇","中方县","中方镇","会同县","林城镇","麻阳苗族自治县","高村镇","新晃侗族自治县","新晃镇","芷江侗族自治县","芷江镇","靖州苗族侗族自治县","渠阳镇","通道侗族自治县","双江镇"]
                                },
                                {
                                    name:"娄底市",
                                    districtAndCounty:["娄星区","冷水江市","涟源市","双峰县","永丰镇","新化县","上梅镇"]
                                },
                                {
                                    name:"湘西州",
                                    districtAndCounty:["吉首市","泸溪县","白沙镇","凤凰县","沱江镇","花垣县","花垣镇","保靖县","迁陵镇","古丈县","古阳镇","永顺县","灵溪镇","龙山县"]
                                }
                            ]
                        },
                        {
                            name:"广东省",
                            city:[
                                {
                                    name:"广州市",
                                    districtAndCounty:["越秀区","荔湾区","海珠区","天河区","白云区","黄埔区","番禺区","花都区","南沙区","萝岗区","增城市","从化市"]
                                },
                                {
                                    name:"深圳市",
                                    districtAndCounty:["福田区","罗湖区","南山区","宝安区","龙岗区","盐田区"]
                                },
                                {
                                    name:"清远市",
                                    districtAndCounty:["清城区","英德市","连州市","佛冈县","石角镇","阳山县","阳城镇","清新县","太和镇","连山壮族瑶族自治县","吉田镇","连南瑶族自治县","三江镇"]
                                },
                                {
                                    name:"韶关市",
                                    districtAndCounty:["浈江区","武江区","曲江区","乐昌市","南雄市","始兴县","太平镇","仁化县","仁化镇","翁源县","龙仙镇","新丰县","乳源瑶族自治县","乳城镇"]
                                },
                                {
                                    name:"河源市",
                                    districtAndCounty:["源城区","紫金县","紫城镇","龙川县","老隆镇","连平县","元善镇","和平县","阳明镇","东源县","仙塘镇"]
                                },
                                {
                                    name:"梅州市",
                                    districtAndCounty:["梅江区","兴宁市","梅县","程江镇","大埔县","湖寮镇","丰顺县","汤坑镇","五华县","水寨镇","平远县","大柘镇","蕉岭县","蕉城镇"]
                                },
                                {
                                    name:"潮州市",
                                    districtAndCounty:["湘桥区","潮安县","庵埠镇","饶平县","黄冈镇"]
                                },
                                {
                                    name:"汕头市",
                                    districtAndCounty:["金平区","濠江区","龙湖区","潮阳区","潮南区","澄海区","南澳县","后宅镇"]
                                },
                                {
                                    name:"揭阳市",
                                    districtAndCounty:["榕城区","普宁市","揭东县","曲溪镇","揭西县","河婆镇","惠来县","惠城镇"]
                                },
                                {
                                    name:"汕尾市",
                                    districtAndCounty:["城区","陆丰市","海丰县","海城镇","陆河县","河田镇"]
                                },
                                {
                                    name:"惠州市",
                                    districtAndCounty:["惠城区","惠阳区","博罗县","罗阳镇","惠东县","龙门县"]
                                },
                                {
                                    name:"东莞市",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"珠海市",
                                    districtAndCounty:["香洲区","斗门区","金湾区"]
                                },
                                {
                                    name:"中山市",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"江门市",
                                    districtAndCounty:["江海区","蓬江区","新会区","恩平市","台山市","开平市","鹤山市"]
                                },
                                {
                                    name:"佛山市",
                                    districtAndCounty:["禅城区","南海区","顺德区","三水区","高明区"]
                                },
                                {
                                    name:"肇庆市",
                                    districtAndCounty:["端州区","鼎湖区","高要市","四会市","广宁县","南街镇","怀集县","怀城镇","封开县","江口镇","德庆县"]
                                },
                                {
                                    name:"云浮市",
                                    districtAndCounty:["云城区","罗定市","云安县","六都镇","新兴县","新城镇","郁南县","都城镇"]
                                },
                                {
                                    name:"阳江市",
                                    districtAndCounty:["江城区","阳春市","阳西县","织镇","阳东县","东城镇"]
                                },
                                {
                                    name:"茂名市",
                                    districtAndCounty:["茂南区","茂港区","化州市","信宜市","高州市","电白县","水东镇"]
                                },
                                {
                                    name:"湛江市",
                                    districtAndCounty:["赤坎区","霞山区","坡头区","麻章区","吴川市","廉江市","雷州市","遂溪县","遂城镇","徐闻县","撤销广州市东山区","芳村区","设立广州市南沙区","萝岗区"]
                                }
                            ]
                        },
                        {
                            name:"广西",
                            city:[
                                {
                                    name:"南宁市",
                                    districtAndCounty:["青秀区","兴宁区","江南区","西乡塘区","良庆区","邕宁区","武鸣县","横县","宾阳县","上林县","隆安县","马山县"]
                                },
                                {
                                    name:"桂林市",
                                    districtAndCounty:["象山区","叠彩区","秀峰区","七星区","雁山区","阳朔县","阳朔镇","临桂县","临桂镇","灵川县","灵川镇","全州县","全州镇","兴安县","兴安镇","永福县","永福镇","灌阳县","灌阳镇","资源县","资源镇","平乐县","平乐镇","荔浦县","荔城镇","龙胜各族自治县","龙胜镇","恭城瑶族自治县","恭城镇"]
                                },
                                {
                                    name:"柳州市",
                                    districtAndCounty:["城中区","鱼峰区","柳南区","柳北区","柳江县","拉堡镇","柳城县","大埔镇","鹿寨县","鹿寨镇","融安县","长安镇","三江侗族自治县","古宜镇","融水苗族自治县","融水镇"]
                                },
                                {
                                    name:"梧州市",
                                    districtAndCounty:["万秀区","蝶山区","长洲区","岑溪市","苍梧县","龙圩镇","藤县","藤州镇","蒙山县","蒙山镇"]
                                },
                                {
                                    name:"贵港市",
                                    districtAndCounty:["港北区","港南区","覃塘区","桂平市","平南县","平南镇"]
                                },
                                {
                                    name:"玉林市",
                                    districtAndCounty:["玉州区","北流市","兴业县","石南镇","容县","容州镇","陆川县","陆城镇","博白县","博白镇"]
                                },
                                {
                                    name:"钦州市",
                                    districtAndCounty:["钦南区","钦北区","灵山县","灵城镇","浦北县","小江镇"]
                                },
                                {
                                    name:"北海市",
                                    districtAndCounty:["海城区","银海区","铁山港区","合浦县","廉州镇"]
                                },
                                {
                                    name:"防城港市",
                                    districtAndCounty:["港口区","防城区","东兴市","上思县","思阳镇"]
                                },
                                {
                                    name:"崇左市",
                                    districtAndCounty:["江州区","凭祥市","扶绥县","新宁镇","大新县","桃城镇","天等县","天等镇","宁明县","城中镇","龙州县","龙州镇"]
                                },
                                {
                                    name:"百色市",
                                    districtAndCounty:["右江区","田阳县","田州镇","田东县","平马镇","平果县","马头镇","德保县","城关镇","靖西县","新靖镇","那坡县","城厢镇","凌云县","泗城镇","乐业县","同乐镇","西林县","八达镇","田林县","乐里镇","隆林各族自治县","新州镇"]
                                },
                                {
                                    name:"河池市",
                                    districtAndCounty:["金城江区","宜州市","南丹县","城关镇","天峨县","六排镇","凤山县","凤城镇","东兰县","东兰镇","巴马瑶族自治县","巴马镇","都安瑶族自治县","安阳镇","大化瑶族自治县","大化镇","罗城仫佬族自治县","东门镇","环江毛南族自治县","思恩镇"]
                                },
                                {
                                    name:"来宾市",
                                    districtAndCounty:["兴宾区","合山市","象州县","象州镇","武宣县","武宣镇","忻城县","城关镇","金秀瑶族自治县","金秀镇"]
                                },
                                {
                                    name:"贺州市",
                                    districtAndCounty:["八步区","昭平县","昭平镇","钟山县","钟山镇","富川瑶族自治县","富阳镇"]
                                }
                            ]
                        },
                        {
                            name:"海南省",
                            city:[
                                {
                                    name:"海口市",
                                    districtAndCounty:["龙华区","秀英区","琼山区","美兰区"]
                                },
                                {
                                    name:"三亚市",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"省直辖行政单位",
                                    districtAndCounty:["文昌市","琼海市","万宁市","五指山市","东方市","儋州市","临高县","临城镇","澄迈县","金江镇","定安县","定城镇","屯昌县","屯城镇","昌江黎族自治县","石碌镇","白沙黎族自治县","牙叉镇","琼中黎族苗族自治县","营根镇","陵水黎族自治县","椰林镇","保亭黎族苗族自治县","保城镇","乐东黎族自治县","抱由镇"]
                                }
                            ]
                        },
                        {
                            name:"四川省",
                            city:[
                                {
                                    name:"成都市",
                                    districtAndCounty:["青羊区","锦江区","金牛区","武侯区","成华区","龙泉驿区","青白江区","新都区","温江区","都江堰市","彭州市","邛崃市","崇州市","金堂县","赵镇","双流县","郫县","郫筒镇","大邑县","晋原镇","蒲江县","鹤山镇","新津县","五津镇"]
                                },
                                {
                                    name:"广元市",
                                    districtAndCounty:["市中区","元坝区","朝天区","旺苍县","东河镇","青川县","乔庄镇","剑阁县","下寺镇","苍溪县","陵江镇"]
                                },
                                {
                                    name:"绵阳市",
                                    districtAndCounty:["涪城区","游仙区","江油市","三台县","潼川镇","盐亭县","云溪镇","安县","花荄镇","梓潼县","文昌镇","北川羌族自治县","曲山镇","平武县","龙安镇"]
                                },
                                {
                                    name:"德阳市",
                                    districtAndCounty:["旌阳区","什邡市","广汉市","绵竹市","罗江县","罗江镇","中江县","凯江镇"]
                                },
                                {
                                    name:"南充市",
                                    districtAndCounty:["顺庆区","高坪区","嘉陵区","阆中市","南部县","南隆镇","营山县","朗池镇","蓬安县","周口镇","仪陇县","新政镇","西充县","晋城镇"]
                                },
                                {
                                    name:"广安市",
                                    districtAndCounty:["广安区","华蓥市","岳池县","九龙镇","武胜县","沿口镇","邻水县","鼎屏镇"]
                                },
                                {
                                    name:"遂宁市",
                                    districtAndCounty:["船山区","安居区","蓬溪县","赤城镇","射洪县","太和镇","大英县","蓬莱镇"]
                                },
                                {
                                    name:"内江市",
                                    districtAndCounty:["市中区","东兴区","威远县","严陵镇","资中县","重龙镇","隆昌县","金鹅镇"]
                                },
                                {
                                    name:"乐山市",
                                    districtAndCounty:["市中区","沙湾区","五通桥区","金口河区","峨眉山市","犍为县","玉津镇","井研县","研城镇","夹江县","漹城镇","沐川县","沐溪镇","峨边彝族自治县","沙坪镇","马边彝族自治县","民建镇"]
                                },
                                {
                                    name:"自贡市",
                                    districtAndCounty:["自流井区","大安区","贡井区","沿滩区","荣县","旭阳镇","富顺县","富世镇"]
                                },
                                {
                                    name:"泸州市",
                                    districtAndCounty:["江阳区","纳溪区","龙马潭区","泸县","福集镇","合江县","合江镇","叙永县","叙永镇","古蔺县","古蔺镇"]
                                },
                                {
                                    name:"宜宾市",
                                    districtAndCounty:["翠屏区","宜宾县","柏溪镇","南溪县","南溪镇","江安县","江安镇","长宁县","长宁镇","高县","庆符镇","筠连县","筠连镇","珙县","巡场镇","兴文县","中城镇","屏山县","屏山镇"]
                                },
                                {
                                    name:"攀枝花市",
                                    districtAndCounty:["东区","西区","仁和区","米易县","攀莲镇","盐边县","桐子林镇"]
                                },
                                {
                                    name:"巴中市",
                                    districtAndCounty:["巴州区","通江县","诺江镇","南江县","南江镇","平昌县","江口镇"]
                                },
                                {
                                    name:"达州市",
                                    districtAndCounty:["通川区","万源市","达县","南外镇","宣汉县","东乡镇","开江县","新宁镇","大竹县","竹阳镇","渠县","渠江镇"]
                                },
                                {
                                    name:"资阳市",
                                    districtAndCounty:["雁江区","简阳市","乐至县","天池镇","安岳县","岳阳镇"]
                                },
                                {
                                    name:"眉山市",
                                    districtAndCounty:["东坡区","仁寿县","文林镇","彭山县","凤鸣镇","洪雅县","洪川镇","丹棱县","丹棱镇","青神县","城厢镇"]
                                },
                                {
                                    name:"雅安市",
                                    districtAndCounty:["雨城区","名山县","蒙阳镇","荥经县","严道镇","汉源县","富林镇","石棉县","新棉镇","天全县","城厢镇","芦山县","芦阳镇","宝兴县","穆坪镇"]
                                },
                                {
                                    name:"阿坝州",
                                    districtAndCounty:["马尔康县","马尔康镇","汶川县","威州镇","理县","杂谷脑镇","茂县","凤仪镇","松潘县","进安镇","九寨沟县","永乐镇","金川县","金川镇","小金县","美兴镇","黑水县","芦花镇","壤塘县","壤柯镇","阿坝县","阿坝镇","若尔盖县","达扎寺镇","红原县","邛溪镇"]
                                },
                                {
                                    name:"甘孜州",
                                    districtAndCounty:["康定县","炉城镇","泸定县","泸桥镇","丹巴县","章谷镇","九龙县","呷尔镇","雅江县","河口镇","道孚县","鲜水镇","炉霍县","新都镇","甘孜县","甘孜镇","新龙县","茹龙镇","德格县","更庆镇","白玉县","建设镇","石渠县","尼呷镇","色达县","色柯镇","理塘县","高城镇","巴塘县","夏邛镇","乡城县","桑披镇","稻城县","金珠镇","得荣县","松麦镇"]
                                },
                                {
                                    name:"凉山州",
                                    districtAndCounty:["西昌市","盐源县","盐井镇","德昌县","德州镇","会理县","城关镇","会东县","会东镇","宁南县","披砂镇","普格县","普基镇","布拖县","特木里镇","金阳县","天地坝镇","昭觉县","新城镇","喜德县","光明镇","冕宁县","城厢镇","越西县","越城镇","甘洛县","新市坝镇","美姑县","巴普镇","雷波县","锦城镇","木里藏族自治县","乔瓦镇"]
                                }
                            ]
                        },
                        {
                            name:"贵州省",
                            city:[
                                {
                                    name:"贵阳市",
                                    districtAndCounty:["乌当区","南明区","云岩区","花溪区","白云区","小河区","清镇市","开阳县","城关镇","修文县","龙场镇","息烽县","永靖镇"]
                                },
                                {
                                    name:"六盘水市",
                                    districtAndCounty:["钟山区","盘县","红果镇","六枝特区","平寨镇","水城县"]
                                },
                                {
                                    name:"遵义市",
                                    districtAndCounty:["红花岗区","汇川区","赤水市","仁怀市","遵义县","南白镇","桐梓县","娄山关镇","绥阳县","洋川镇","正安县","凤仪镇","凤冈县","龙泉镇","湄潭县","湄江镇","余庆县","白泥镇","习水县","东皇镇","道真仡佬族苗族自治县","玉溪镇","务川仡佬族苗族自治县","都濡镇"]
                                },
                                {
                                    name:"安顺市",
                                    districtAndCounty:["西秀区","平坝县","城关镇","普定县","城关镇","关岭布依族苗族自治县","关索镇","镇宁布依族苗族自治县","城关镇","紫云苗族布依族自治县","松山镇"]
                                },
                                {
                                    name:"毕节地区",
                                    districtAndCounty:["毕节市","大方县","大方镇","黔西县","城关镇","金沙县","城关镇","织金县","城关镇","纳雍县","雍熙镇","赫章县","城关镇","威宁彝族回族苗族自治县","草海镇"]
                                },
                                {
                                    name:"铜仁地区",
                                    districtAndCounty:["铜仁市","江口县","双江镇","石阡县","汤山镇","思南县","思唐镇","德江县","青龙镇","玉屏侗族自治县","平溪镇","印江土家族苗族自治县","峨岭镇","沿河土家族自治县","和平镇","松桃苗族自治县","蓼皋镇","万山特区","万山镇"]
                                },
                                {
                                    name:"黔东南州",
                                    districtAndCounty:["凯里市","黄平县","新州镇","施秉县","城关镇","三穗县","八弓镇","镇远县","阳镇","岑巩县","思旸镇","天柱县","凤城镇","锦屏县","三江镇","剑河县","革东镇","台江县","台拱镇","黎平县","德凤镇","榕江县","古州镇","从江县","丙妹镇","雷山县","丹江镇","麻江县","杏山镇","丹寨县","龙泉镇"]
                                },
                                {
                                    name:"黔南州",
                                    districtAndCounty:["都匀市","福泉市","荔波县","玉屏镇","贵定县","城关镇","瓮安县","雍阳镇","独山县","城关镇","平塘县","平湖镇","罗甸县","龙坪镇","长顺县","长寨镇","龙里县","龙山镇","惠水县","和平镇","三都水族自治县","三合镇"]
                                },
                                {
                                    name:"黔西南州",
                                    districtAndCounty:["兴义市","兴仁县","城关镇","普安县","盘水镇","晴隆县","莲城镇","贞丰县","珉谷镇","望谟县","复兴镇","册亨县","者楼镇","安龙县","新安镇"]
                                }
                            ]
                        },
                        {
                            name:"云南省",
                            city:[
                                {
                                    name:"昆明市",
                                    districtAndCounty:["盘龙区","五华区","官渡区","西山区","东川区","安宁市","呈贡县","龙城镇","晋宁县","昆阳镇","富民县","永定镇","宜良县","匡远镇","嵩明县","嵩阳镇","石林彝族自治县","鹿阜镇","禄劝彝族苗族自治县","屏山镇","寻甸回族彝族自治县","仁德镇"]
                                },
                                {
                                    name:"曲靖市",
                                    districtAndCounty:["麒麟区","宣威市","马龙县","通泉镇","沾益县","西平镇","富源县","中安镇","罗平县","罗雄镇","师宗县","丹凤镇","陆良县","中枢镇","会泽县","金钟镇"]
                                },
                                {
                                    name:"玉溪市",
                                    districtAndCounty:["红塔区","江川县","大街镇","澄江县","凤麓镇","通海县","秀山镇","华宁县","宁州镇","易门县","龙泉镇","峨山彝族自治县","双江镇","新平彝族傣族自治县","桂山镇","元江哈尼族彝族傣族自治县","澧江镇"]
                                },
                                {
                                    name:"保山市",
                                    districtAndCounty:["隆阳区","施甸县","甸阳镇","腾冲县","腾越镇","龙陵县","龙山镇","昌宁县","田园镇"]
                                },
                                {
                                    name:"昭通市",
                                    districtAndCounty:["昭阳区","鲁甸县","文屏镇","巧家县","新华镇","盐津县","盐井镇","大关县","翠华镇","永善县","溪落渡镇","绥江县","中城镇","镇雄县","乌峰镇","彝良县","角奎镇","威信县","扎西镇","水富县","向家坝镇"]
                                },
                                {
                                    name:"丽江市",
                                    districtAndCounty:["古城区","永胜县","永北镇","华坪县","中心镇","玉龙纳西族自治县","黄山镇","宁蒗彝族自治县","大兴镇"]
                                },
                                {
                                    name:"思茅市",
                                    districtAndCounty:["翠云区","普洱哈尼族彝族自治县","宁洱镇","墨江哈尼族自治县","联珠镇","景东彝族自治县","锦屏镇","景谷傣族彝族自治县","威远镇","镇沅彝族哈尼族拉祜族自治县","恩乐镇","江城哈尼族彝族自治县","勐烈镇","孟连傣族拉祜族佤族自治县","娜允镇","澜沧拉祜族自治县","勐朗镇","西盟佤族自治县","勐梭镇"]
                                },
                                {
                                    name:"临沧市",
                                    districtAndCounty:["临翔区","凤庆县","凤山镇","云县","爱华镇","永德县","德党镇","镇康县","南伞镇","双江拉祜族佤族布朗族傣族自治县","勐勐镇","耿马傣族佤族自治县","耿马镇","沧源佤族自治县","勐董镇"]
                                },
                                {
                                    name:"德宏州",
                                    districtAndCounty:["潞西市","瑞丽市","梁河县","遮岛镇","盈江县","平原镇","陇川县","章凤镇"]
                                },
                                {
                                    name:"怒江州",
                                    districtAndCounty:["泸水县六库镇","泸水县","六库镇","福贡县","上帕镇","贡山独龙族怒族自治县","茨开镇","兰坪白族普米族自治县","金顶镇"]
                                },
                                {
                                    name:"迪庆州",
                                    districtAndCounty:["香格里拉县","建塘镇","德钦县","升平镇","维西傈僳族自治县","保和镇"]
                                },
                                {
                                    name:"大理州",
                                    districtAndCounty:["大理市","祥云县","祥城镇","宾川县","金牛镇","弥渡县","弥城镇","永平县","博南镇","云龙县","诺邓镇","洱源县","茈碧湖镇","剑川县","金华镇","鹤庆县","云鹤镇","漾濞彝族自治县","苍山西镇","南涧彝族自治县","南涧镇","巍山彝族回族自治县","南诏镇"]
                                },
                                {
                                    name:"楚雄州",
                                    districtAndCounty:["楚雄市","双柏县","妥甸镇","牟定县","共和镇","南华县","龙川镇","姚安县","栋川镇","大姚县","金碧镇","永仁县","永定镇","元谋县","元马镇","武定县","狮山镇","禄丰县","金山镇"]
                                },
                                {
                                    name:"红河州",
                                    districtAndCounty:["蒙自县","文澜镇","个旧市","开远市","绿春县","大兴镇","建水县","临安镇","石屏县","异龙镇","弥勒县","弥阳镇","泸西县","中枢镇","元阳县","南沙镇","红河县","迤萨镇","金平苗族瑶族傣族自治县","金河镇","河口瑶族自治县","河口镇","屏边苗族自治县","玉屏镇"]
                                },
                                {
                                    name:"文山州",
                                    districtAndCounty:["文山县","开化镇","砚山县","江那镇","西畴县","西洒镇","麻栗坡县","麻栗镇","马关县","马白镇","丘北县","锦屏镇","广南县","莲城镇","富宁县","新华镇"]
                                },
                                {
                                    name:"西双版纳州",
                                    districtAndCounty:["景洪市","勐海县","勐海镇","勐腊县","勐腊镇"]
                                }
                            ]
                        },
                        {
                            name:"西藏",
                            city:[
                                {
                                    name:"拉萨市",
                                    districtAndCounty:["城关区","林周县","甘丹曲果镇","当雄县","当曲卡镇","尼木县","塔荣镇","曲水县","曲水镇","堆龙德庆县","东嘎镇","达孜县","德庆镇","墨竹工卡县","工卡镇"]
                                },
                                {
                                    name:"那曲地区",
                                    districtAndCounty:["那曲县","那曲镇","嘉黎县","阿扎镇","比如县","比如镇","聂荣县","聂荣镇","安多县","帕那镇","申扎县","申扎镇","索县","亚拉镇","班戈县","普保镇","巴青县","拉西镇","尼玛县","尼玛镇"]
                                },
                                {
                                    name:"昌都地区",
                                    districtAndCounty:["昌都县","城关镇","江达县","江达镇","贡觉县","莫洛镇","类乌齐县","桑多镇","丁青县","丁青镇","察雅县","烟多镇","八宿县","白玛镇","左贡县","旺达镇","芒康县","嘎托镇","洛隆县","孜托镇","边坝县","草卡镇"]
                                },
                                {
                                    name:"林芝地区",
                                    districtAndCounty:["林芝县","八一镇","工布江达县","工布江达镇","米林县","米林镇","墨脱县","墨脱镇","波密县","扎木镇","察隅县","竹瓦根镇","朗县","朗镇"]
                                },
                                {
                                    name:"山南地区",
                                    districtAndCounty:["乃东县","泽当镇","扎囊县","扎塘镇","贡嘎县","吉雄镇","桑日县","桑日镇","琼结县","琼结镇","曲松县","曲松镇","措美县","措美镇","洛扎县","洛扎镇","加查县","安绕镇","隆子县","隆子镇","错那县","错那镇","浪卡子县","浪卡子镇"]
                                },
                                {
                                    name:"日喀则地区",
                                    districtAndCounty:["日喀则市","南木林县","南木林镇","江孜县","江孜镇","定日县","协格尔镇","萨迦县","萨迦镇","拉孜县","曲下镇","昂仁县","卡嘎镇","谢通门县","卡嘎镇","白朗县","洛江镇","仁布县","德吉林镇","康马县","康马镇","定结县","江嘎镇","仲巴县","拉让乡","亚东县","下司马镇","吉隆县","宗嘎镇","聂拉木县","聂拉木镇","萨嘎县","加加镇","岗巴县","岗巴镇"]
                                },
                                {
                                    name:"阿里地区",
                                    districtAndCounty:["噶尔县","狮泉河镇","普兰县","普兰镇","札达县","托林镇","日土县","日土镇","革吉县","革吉镇","改则县","改则镇","措勤县","措勤镇","林芝县人民政府驻地由林芝镇迁至八一镇"]
                                }
                            ]
                        },
                        {
                            name:"陕西省",
                            city:[
                                {
                                    name:"西安市",
                                    districtAndCounty:["莲湖区","新城区","碑林区","灞桥区","未央区","雁塔区","阎良区","临潼区","长安区","蓝田县","蓝关镇","周至县","二曲镇","户县","甘亭镇","高陵县","鹿苑镇"]
                                },
                                {
                                    name:"延安市",
                                    districtAndCounty:["宝塔区","延长县","七里村镇","延川县","延川镇","子长县","瓦窑堡镇","安塞县","真武洞镇","志丹县","保安镇","吴起县","吴旗镇","甘泉县","城关镇","富县","富城镇","洛川县","凤栖镇","宜川县","丹州镇","黄龙县","石堡镇","黄陵县","桥山镇"]
                                },
                                {
                                    name:"铜川市",
                                    districtAndCounty:["耀州区","王益区","印台区","宜君县","城关镇"]
                                },
                                {
                                    name:"渭南市",
                                    districtAndCounty:["临渭区","华阴市","韩城市","华县","华州镇","潼关县","城关镇","大荔县","城关镇","蒲城县","城关镇","澄城县","城关镇","白水县","城关镇","合阳县","城关镇","富平县","窦村镇"]
                                },
                                {
                                    name:"咸阳市",
                                    districtAndCounty:["秦都区","杨陵区","渭城区","兴平市","三原县","城关镇","泾阳县","泾干镇","乾县","城关镇","礼泉县","城关镇","永寿县","监军镇","彬县","城关镇","长武县","昭仁镇","旬邑县","城关镇","淳化县","城关镇","武功县","普集镇"]
                                },
                                {
                                    name:"宝鸡市",
                                    districtAndCounty:["渭滨区","金台区","陈仓区","凤翔县","城关镇","岐山县","凤鸣镇","扶风县","城关镇","眉县","首善镇","陇县","城关镇","千阳县","城关镇","麟游县","九成宫镇","凤县","双石铺镇","太白县","嘴头镇"]
                                },
                                {
                                    name:"汉中市",
                                    districtAndCounty:["汉台区","南郑县","城关镇","城固县","博望镇","洋县","洋州镇","西乡县","城关镇","勉县","勉阳镇","宁强县","汉源镇","略阳县","城关镇","镇巴县","泾洋镇","留坝县","城关镇","佛坪县","袁家庄镇"]
                                },
                                {
                                    name:"榆林市",
                                    districtAndCounty:["榆阳区","神木县","神木镇","府谷县","府谷镇","横山县","横山镇","靖边县","张家畔镇","定边县","定边镇","绥德县","名州镇","米脂县","银州镇","佳县","佳芦镇","吴堡县","宋家川镇","清涧县","宽洲镇","子洲县","双湖峪镇"]
                                },
                                {
                                    name:"安康市",
                                    districtAndCounty:["汉滨区","汉阴县","城关镇","石泉县","城关镇","宁陕县","城关镇","紫阳县","城关镇","岚皋县","城关镇","平利县","城关镇","镇坪县","城关镇","旬阳县","城关镇","白河县","城关镇"]
                                },
                                {
                                    name:"商洛市",
                                    districtAndCounty:["商州区","洛南县","城关镇","丹凤县","龙驹寨镇","商南县","城关镇","山阳县","城关镇","镇安县","永乐镇","柞水县","乾佑镇"]
                                }
                            ]
                        },
                        {
                            name:"甘肃省",
                            city:[
                                {
                                    name:"兰州市",
                                    districtAndCounty:["城关区","七里河区","西固区","安宁区","红古区","永登县","城关镇","皋兰县","石洞镇","榆中县","城关镇"]
                                },
                                {
                                    name:"嘉峪关市",
                                    districtAndCounty:["金昌市","金川区","永昌县","城关镇"]
                                },
                                {
                                    name:"白银市",
                                    districtAndCounty:["白银区","平川区","靖远县","乌兰镇","会宁县","会师镇","景泰县","一条山镇"]
                                },
                                {
                                    name:"天水市",
                                    districtAndCounty:["秦州区","麦积区","清水县","永清镇","秦安县","兴国镇","甘谷县","大像山镇","武山县","城关镇","张家川回族自治县","张家川镇"]
                                },
                                {
                                    name:"武威市",
                                    districtAndCounty:["凉州区","民勤县","城关镇","古浪县","古浪镇","天祝藏族自治县","华藏寺镇"]
                                },
                                {
                                    name:"酒泉市",
                                    districtAndCounty:["肃州区","玉门市","敦煌市","金塔县","金塔镇","安西县","渊泉镇","肃北蒙古族自治县","党城湾镇","阿克塞哈萨克族自治县","红柳湾镇"]
                                },
                                {
                                    name:"张掖市",
                                    districtAndCounty:["甘州区","民乐县","洪水镇","临泽县","沙河镇","高台县","城关镇","山丹县","清泉镇","肃南裕固族自治县","红湾寺镇"]
                                },
                                {
                                    name:"庆阳市",
                                    districtAndCounty:["西峰区","庆城县","庆城镇","环县","环城镇","华池县","柔远镇","合水县","西华池镇","正宁县","山河镇","宁县","新宁镇","镇原县","城关镇"]
                                },
                                {
                                    name:"平凉市",
                                    districtAndCounty:["崆峒区","泾川县","城关镇","灵台县","中台镇","崇信县","锦屏镇","华亭县","东华镇","庄浪县","水洛镇","静宁县","城关镇"]
                                },
                                {
                                    name:"定西市",
                                    districtAndCounty:["安定区","通渭县","平襄镇","临洮县","洮阳镇","漳县","武阳镇","岷县","岷阳镇","渭源县","清源镇","陇西县","巩昌镇"]
                                },
                                {
                                    name:"陇南市",
                                    districtAndCounty:["武都区","成县","城关镇","宕昌县","城关镇","康县","文县","城关镇","西和县","汉源镇","礼县","城关镇","两当县","城关镇","徽县","城关镇"]
                                },
                                {
                                    name:"临夏州",
                                    districtAndCounty:["临夏市","临夏县","韩集镇","康乐县","附城镇","永靖县","刘家峡镇","广河县","城关镇","和政县","城关镇","东乡族自治县","锁南坝镇","积石山保安族东乡族撒拉族自治县","吹麻滩镇"]
                                },
                                {
                                    name:"甘南州",
                                    districtAndCounty:["合作市","临潭县","城关镇","卓尼县","柳林镇","舟曲县","城关镇","迭部县","电尕镇","玛曲县","尼玛镇","碌曲县","玛艾镇","夏河县","拉卜楞镇"]
                                }
                            ]
                        },
                        {
                            name:"青海省",
                            city:[
                                {
                                    name:"西宁市",
                                    districtAndCounty:["城中区","城东区","城西区","城北区","大通回族土族自治县","桥头镇","湟源县","城关镇","湟中县","鲁沙尔镇"]
                                },
                                {
                                    name:"海东地区",
                                    districtAndCounty:["平安县","平安镇","乐都县","碾伯镇","民和回族土族自治县","川口镇","互助土族自治县","威远镇","化隆回族自治县","巴燕镇","循化撒拉族自治县","积石镇"]
                                },
                                {
                                    name:"海北州",
                                    districtAndCounty:["海晏县","三角城镇","祁连县","八宝镇","刚察县","沙柳河镇","门源回族自治县","浩门镇"]
                                },
                                {
                                    name:"海南州",
                                    districtAndCounty:["共和县","恰卜恰镇","同德县","尕巴松多镇","贵德县","河阴镇","兴海县","子科滩镇","贵南县","茫曲镇"]
                                },
                                {
                                    name:"黄南州",
                                    districtAndCounty:["同仁县","隆务镇","尖扎县","马克唐镇","泽库县","泽曲镇","河南蒙古族自治县","优干宁镇"]
                                },
                                {
                                    name:"果洛州",
                                    districtAndCounty:["玛沁县","大武镇","班玛县","赛来塘镇","甘德县","柯曲镇","达日县","吉迈镇","久治县","智青松多镇","玛多县","黄河乡"]
                                },
                                {
                                    name:"玉树州",
                                    districtAndCounty:["玉树县","结古镇","杂多县","萨呼腾镇","称多县","称文镇","治多县","加吉博洛镇","囊谦县","香达镇","曲麻莱县","约改镇"]
                                },
                                {
                                    name:"海西州",
                                    districtAndCounty:["德令哈市","格尔木市","乌兰县","希里沟镇","都兰县","察汗乌苏镇","天峻县","新源镇"]
                                }
                            ]
                        },
                        {
                            name:"宁夏",
                            city:[
                                {
                                    name:"银川市",
                                    districtAndCounty:["兴庆区","金凤区","西夏区","灵武市","永宁县","杨和镇","贺兰县","习岗镇"]
                                },
                                {
                                    name:"石嘴山市",
                                    districtAndCounty:["大武口区","惠农区","平罗县","城关镇"]
                                },
                                {
                                    name:"吴忠市",
                                    districtAndCounty:["利通区","青铜峡市","盐池县","花马池镇","同心县","豫海镇"]
                                },
                                {
                                    name:"固原市",
                                    districtAndCounty:["原州区","西吉县","吉强镇","隆德县","城关镇","泾源县","香水镇","彭阳县","白阳镇"]
                                },
                                {
                                    name:"中卫市",
                                    districtAndCounty:["沙坡头区","中宁县","海原县"]
                                }
                            ]
                        },
                        {
                            name:"新疆",
                            city:[
                                {
                                    name:"乌鲁木齐市",
                                    districtAndCounty:["天山区","沙依巴克区","新市区","水磨沟区","头屯河区","达坂城区","东山区","乌鲁木齐县","乌鲁木齐市水磨沟区"]
                                },
                                {
                                    name:"克拉玛依市",
                                    districtAndCounty:["克拉玛依区","独山子区","白碱滩区","乌尔禾区"]
                                },
                                {
                                    name:"自治区直辖县级行政单位",
                                    districtAndCounty:["石河子市","阿拉尔市","图木舒克市","五家渠市"]
                                },
                                {
                                    name:"喀什地区",
                                    districtAndCounty:["喀什市","疏附县","托克扎克镇","疏勒县","疏勒镇","英吉沙县","英吉沙镇","泽普县","泽普镇","莎车县","莎车镇","叶城县","喀格勒克镇","麦盖提县","麦盖提镇","岳普湖县","岳普湖镇","伽师县","巴仁镇","巴楚县","巴楚镇","塔什库尔干塔吉克自治县","塔什库尔干镇"]
                                },
                                {
                                    name:"阿克苏地区",
                                    districtAndCounty:["阿克苏市","温宿县","温宿镇","库车县","库车镇","沙雅县","沙雅镇","新和县","新和镇","拜城县","拜城镇","乌什县","乌什镇","阿瓦提县","阿瓦提镇","柯坪县","柯坪镇"]
                                },
                                {
                                    name:"和田地区",
                                    districtAndCounty:["和田市","和田县","墨玉县","喀拉喀什镇","皮山县","固玛镇","洛浦县","洛浦镇","策勒县","策勒镇","于田县","木尕拉镇","民丰县","尼雅镇"]
                                },
                                {
                                    name:"吐鲁番地区",
                                    districtAndCounty:["吐鲁番市","鄯善县","鄯善镇","托克逊县","托克逊镇"]
                                },
                                {
                                    name:"哈密地区",
                                    districtAndCounty:["哈密市","伊吾县","伊吾镇","巴里坤哈萨克自治县","巴里坤镇"]
                                },
                                {
                                    name:"克孜勒苏柯州",
                                    districtAndCounty:["阿图什市","阿克陶县","阿克陶镇","阿合奇县","阿合奇镇","乌恰县","乌恰镇"]
                                },
                                {
                                    name:"博尔塔拉州",
                                    districtAndCounty:["博乐市","精河县","精河镇","温泉县","博格达尔镇"]
                                },
                                {
                                    name:"昌吉州",
                                    districtAndCounty:["昌吉市","阜康市","米泉市","呼图壁县","呼图壁镇","玛纳斯县","玛纳斯镇","奇台县","奇台镇","吉木萨尔县","吉木萨尔镇","木垒哈萨克自治县","木垒镇"]
                                },
                                {
                                    name:"巴音郭楞州",
                                    districtAndCounty:["库尔勒市","轮台县","轮台镇","尉犁县","尉犁镇","若羌县","若羌镇","且末县","且末镇","和静县","和静镇","和硕县","特吾里克镇","博湖县","博湖镇","焉耆回族自治县","焉耆镇"]
                                },
                                {
                                    name:"伊犁州",
                                    districtAndCounty:["伊宁市","奎屯市","伊宁县","吉里于孜镇","霍城县","水定镇","巩留县","巩留镇","新源县","新源镇","昭苏县","昭苏镇","特克斯县","特克斯镇","尼勒克县","尼勒克镇","察布查尔锡伯自治县","察布查尔镇"]
                                },
                                {
                                    name:"塔城地区",
                                    districtAndCounty:["塔城市","乌苏市","额敏县","额敏镇","沙湾县","三道河子镇","托里县","托里镇","裕民县","哈拉布拉镇","和布克赛尔蒙古自治县","和布克赛尔镇"]
                                },
                                {
                                    name:"阿勒泰地区",
                                    districtAndCounty:["阿勒泰市","布尔津县","布尔津镇","富蕴县","库额尔齐斯镇","福海县","哈巴河县","青河县","吉木乃县"]
                                }
                            ]
                        },
                        {
                            name:"香港",
                            city:[
                                {
                                    name:"香港特别行政区",
                                    districtAndCounty:["中西区","东区","九龙城区","观塘区","南区","深水埗区","湾仔区","黄大仙区","油尖旺区","离岛区","葵青区","北区","西贡区","沙田区","屯门区","大埔区","荃湾区","元朗区"]
                                }
                            ]
                        },
                        {
                            name:"澳门",
                            city:[
                                {
                                    name:"澳门特别行政区",
                                    districtAndCounty:["澳门特别行政区"]
                                }
                            ]
                        },
                        {
                            name:"台湾省",
                            city:[
                                {
                                    name:"台北",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"高雄",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"台中",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"花莲",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"基隆",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"嘉义",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"金门",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"连江",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"苗栗",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"南投",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"澎湖",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"屏东",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"台东",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"台南",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"桃园",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"新竹",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"宜兰",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"云林",
                                    districtAndCounty:[]
                                },
                                {
                                    name:"彰化",
                                    districtAndCounty:[]
                                }
                            ]
                        }
                    ],

            setProvince: function(){
                var self = this;
                var pro=$("#province");
                var city=$("#city");
                //var dAC=$("#districtAndCounty");
                var num1=null;
                var num2=null;
                for(var i=0;i<self.province.length;i++){
                    var $temp=$("<option value='" + self.province[i].name + "'>"+self.province[i].name+"</option>");
                    pro.append($temp);
                }
                pro.change(function(){
                    num1=pro.prop("selectedIndex");
                    city.find("option").eq(0).siblings().remove();
                    //dAC.find("option").eq(0).siblings().remove();
                    if(num1!==0){
                        for(var i=0;i<self.province[num1-1].city.length;i++){
                            var $temp=$("<option value='" + self.province[num1-1].city[i].name + "'>"+self.province[num1-1].city[i].name+"</option>");
                            city.append($temp);
                        }
                    }
                });
            },




            formatClusterName:function(v,r){
                if(v=='null'){
                    return '待分配集群';
                }

                return v+'<span class="assigned"></span>';
            },

            formatClusterStatus: function (v, r) {
                return Server.Config.CLUSTER_STATUS[v];
            },
            formatUser: function (v, r) {
                return v.substr(0,v.indexOf('@'));
            },

            formatOpt: function (v, r) {
                var modify = '<a target="_blank" href=edit_cluster.html?id='+r.id+'>修改</a>';
                var del = "<a href='javascript:void(0);' onclick='Server.Util.delCluster("+ r.id + ");'>删除</a>";
                return modify + "   " + del;
            },

            delCluster: function(id){
                var self = this;
                SystemDialog.queryConfirm("是否从列表中删除该集群？", function (flag) {
                    if (flag == true) {
                        var params = {'id' : id};
                        Server.Dao.delServerCluster(params, function(data){
                            if(data.code == 'A00000'){
                                Server.Util.logTips({type: "success", content: "删除成功"});
                                $('.search').click();

                            }else if(data.code == 'A00001'){
                                if(data.data == '-1111'){
                                    Server.Util.logTips({theme: "error", content: "正在收录任务，不可删除"});
                                }else{
                                    Server.Util.logTips({theme: "error", content: "删除失败"});
                                }
                            }
                        });
                    }
                    return true;
                });
            },

            getClusterList:function($container){
                var $selector = $container.find('select[name="clusterId"]');

                Server.Dao.clusterList({"pageSize":"300"},function(rdata){
                    $selector.empty();
                    $selector.append( $('<option>').val('all').html('全部' ));

                    var result = rdata['data']['result'];
                    for(var i=0;i<result.length;i++){
                        var $opt = $('<option>').val(result[i]['id']).html(result[i]['name']);
                        $selector.append($opt);
                    }
                });
            },
		});
});
define(
    '../server/Server.Grid',['require','exports','module'],function(require, exports, module) {

        Server.Grid = function(options) {
            this.dao = Server.Dao;
            this.config = Server.Config;
            this.util = Server.Util;
            this.options = options || {};
            this.construct = options.construct || function() {
                this.init();
            };
            this.construct.call(this);
        };

        Com.inherits(Server.Grid, Ancestor.Grid).extend({
            flag:0,
            init: function() {
                var self = this;
                var $container = self.options.$container;
                self.$grid = $container.find('table.grid');
                self.orderNum=[1,1,1,1,1,1,1];
                Server.Util.getClusterList(self.options.$container);
                self.perpareData();
                self.bindBasicEvent();
                self.initSuggest();
            },

            perpareData: function() {
                var self = this;
                var username = $("div.user a.name").html();
                Server.Util.setProvince();
            },

            bindBasicEvent: function() {
                var self = this;

                var $container = self.options.$container;

                $container.find('.query-add').click(function() {
					window.open("/epg/server_edit.html");
                });

                $container.find(".query-btn").on('click.query', function() {
                    //self.flag=0;
                    self.query(self.flag);
                    return false;
                });

                $container.find('.zzd-server').click(function(){
                    window.open("/epg/zzd_server.html");
                })

                $(document).keydown(function(e){
                    if(e.altKey && e.which==13){
                        if(self.flag==0){
                            self.flag=1
                        }else{
                            self.flag=0;
                        }
                        self.query(self.flag);
                        console.log(self.flag)
                    }
                })

                $container.find("select[name='monitor1']").change(function () {
                    if($(this).val()=='err'){
                        $container.find("select[name='monitor2']").show();
                    }else {
                        $container.find("select[name='monitor2']").hide();
                    }
                });

                $container.find("button[type='reset']").click(function(){
                    $container.find("select[name='monitor2']").hide();
                    $container.find("input[name='clusterId']").removeAttr('data-id');
                });
			},

			bindFormEvent: function($form) {
                var self = this;
			},
            jqLoadComplete:function(){
                var self=this;
                $(".ui-jqgrid-htable").eq(0).find('div').each(function(i,ele){
                    //指明可排序 位置
                    if(i>=11&&i<=17){
                        self.util.loadOrder('none',$(ele));
                        $(ele).find('span').eq(0).css('display','inline');
                    }
                });
                Server.Util.difMonitorNull();

            },

            run: function(options, callback) {
                var self = this;
                var gridConfig = self.getGridConfig();
                var id=location.search;
                var data={};
                if(id&&id!=""){
                    id = id.slice(1).split("=")[1];
                    data = {postData:{'id':id}};
                }
                options = $.extend(true, {
                    width: 1500,
                    shrinkToFit: false,
                    // idPrefix: 'Video-',
                    autowidth: false,
                    loadComplete:function(){
                        self.jqLoadComplete();
                        self.query(0);
                    },
                    
                    onSortCol:function(index,name){
                        var morder;
                        if(self.orderNum[name-11]%2==0){
                            morder='asc';
                        }else{
                            morder='desc';
                        }
                        self.$grid.setGridParam( {
                            sortorder:morder,
                            loadComplete:function(){
                                self.jqLoadComplete();
                                 var $ddiv=$(".ui-jqgrid-htable").eq(0).find('div').eq(name);
                                 self.util.loadOrder(morder,$ddiv);
                            }
                        }).trigger('reloadGrid', [{
                            page: 1,
                        }]);
                        self.orderNum[name-11]++;
                        return 'stop';
                    },
                }, gridConfig, options,data);

                self.$grid.jqGrid(options);



                var colModelConfig = Server.Config.TABLE_STATUS_COLMODEL_CONFIG;

                var tableConfig = $.extend(true, {}, Server.Config.TABLE_STATUS );
                tableConfig.width =  1500;
                var colModel = tableConfig.colModel;
                var newColModel = [];

                $.each(colModel, function(i, model) {
                    newColModel.push(colModelConfig[model]);
                });
                tableConfig.colModel = newColModel;
                $('#serverStatusList').jqGrid(tableConfig);
            },

            getParam: function() {
                var self = this;
                var $container = self.options.$container;

                var $grid = self.$grid;
                var params = {};
                var $form = $container.find('form[name="basicFrm"]');

                var $elements = $.makeArray($form.prop('elements')).filter(function(item) {
					return true;
                });

				var checkboxVal = [];
                var name;
                var key;
                var flag=0;
                $.each($elements, function() {
                    name = this.name;
                    if (name) {
						if(name=='monitor1')	{
                            if($(this).val()=='err'){
                                flag=1;
                            }
                            else{
                                params['monitor'] = $.trim($(this).val());
                            }
						}else if(name=='monitor2'&&flag==1){
                            params['monitor'] = $.trim($(this).val());
                        }else if(name == 'clusterId'){
                            params['cluster'] = $("input[name=clusterId]").suggest("getValue");
                        }else {
							if($(this).val()){
								params[name] = $.trim($(this).val());
							}
						}
                    }
                });
                return params;
            },

            query: function(flag) {
                var self = this;
                var $container = self.options.$container;
                var $grid = self.$grid;
                self.overridePostData($grid);
                var params = self.getParam();

                if(flag==0){
                    $grid.jqGrid('setGridParam', {
                        postData: params,
                        width: 1350,
                        sortorder:'none',
                        loadComplete:function(){
                            self.jqLoadComplete();
                        },
                    }).hideCol(["load","dataFreePer","allFreePer","availableMemPer","freeSwapPer","inIcmploss","outIcmploss"]).trigger('reloadGrid', [{
                        page: 1,
                    }]);
                }

                if(flag==1){
                    $grid.jqGrid('setGridParam', {
                        postData: params,
                        width: 1900,
                        sortorder:'none',
                        loadComplete:function(){
                            self.jqLoadComplete();
                        },
                    }).showCol(["load","dataFreePer","allFreePer","availableMemPer","freeSwapPer","inIcmploss","outIcmploss"]).trigger('reloadGrid', [{
                        page: 1,
                    }]);
                }

            },

            initSuggest: function () {
                var self = this;
                var ClusterSuggest = {
                    options: {
                        ajaxSettings: {
                            beforeSend: function (request) {
                                var authBase = Ancestor.Util.getAuth("/sginal/server/clusterList");
                                request.setRequestHeader('Sign', authBase.sign);
                                request.setRequestHeader("Time", authBase.clientTime);
                                request.setRequestHeader("From", authBase.from);
                                request.setRequestHeader("UserName", (auth.baseInfo.authInfo == null) ? "" : escape(auth.baseInfo.authInfo.userName).toLocaleLowerCase().replace(/%u/gi, '\\u'));
                            }
                        },
                        select: function (event, object) {
                            var obj = { "clusterName": Number(object.item.id) };
                            // Record.Dao.getColList({paramsObj: JSON.stringify(obj), dataMode: "simple", pageSize: 100}, function (retData) {
                            //     Server.Util.fillRelationColSelect(retData);
                            // })
                            return true;
                        },
                        source: "/api/sginal/server/clusterList",
                        method: "post",
                        autoFilter: false,
                        autoFocus: false,
                        multiple: false,
                        parseValue: function () {
                            var val = this.element.val(),
                                ret = []
                            return ret;
                        },
                        getParam: function (term) {
                            return { "clusterName": $.trim(term) }
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = json.data == null ? null : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data.result, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["id"];
                                itemData[options.labelKey] = item["name"]
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item.label;
                        }
                    }
                }
                $("input[name=clusterId]").suggest(ClusterSuggest.options);
            }

        });

    }
);
define('../server/Server.Edit',['require','exports','module'],function(require, exports, module) {
    Server.Edit = function(options) {
        this.dao = Server.Dao;
        this.options = $.extend(true, {}, options);

        this.util = Server.Util || {};
        this.config = Server.config || {};
    };

    Server.Edit.prototype = {
        oldIdc:'',
        initConfig: function() {
			return true;
		},
        init: function() {
        },

        run: function() {
            var self = this;
            var $container = self.options.$container;
            self.init();
            self.initConfig();

			self.bindEvent();
			self.perpareData();
            self.fillForm();
        },

        perpareData: function() {
            var self = this;
            var username = $("div.user a.name").html();
            Server.Util.setProvince();
        },

        fillForm: function () {
            var id = Server.Util.getUrlId("id");
            var self = this;
            if (id != null) {
                $("input[name=sn]").attr("disabled","disabled");
                self.dao.getList({id: id}, function (data) {
                    var retValue = null;
                    if (data.code === "A00000" && data.data.result != null) {
                        retValue = data.data.result[0];
                        console.log(retValue)
                        self.fillData(retValue);
                        self.oldIdc = retValue['idc'];
                    } else {
                        self.fillNoData();
                    }
                });
            } else {
                self.fillNoData();
            }
        },

        fillData: function (element) {
            var self = this;
            for (var key in element) {
                if (key == "status" || key == "serverType" || key =="city" || key == "idc") {
                    self.options.$container.find("select[name=" + key + "]").val(element[key]);
                    if(key=='serverType'&&element[key]==Server.Config.INCLUDE_TYPE){
                        self.options.$container.find('#include').css('display','block');
                    }

                } else if (key == "province"){
                    self.options.$container.find("select[name=" + key + "]").val(element[key]);
                    self.options.$container.find("select[name=" + key + "]").trigger("change");
                    self.options.$container.find("select[name=city]").val(element["city"]);
                } else {
                    self.options.$container.find("input[name=" + key + "]").val(element[key]);
                }
            }
        },
        fillNoData: function () {
            var self = this;
        },

        bindEvent: function() {
            var self = this;
            var validator = self.getValidator();
            var $container = self.options.$container;
            var $submit = $container.find('#Submit');
            var $type = $container.find('select[name="serverType"]');
            var $include = $container.find('#include');

            $submit.on('click', function() {
                $submit.html('提交中..');
                $submit.attr('disabled','disabled');
                var _save = function(data) {
                    $submit.val('提交中..');
                    if ($('#id').val() != "") {
                        self.edit(data);
                    } else {
                        self.add(data);
                    }
                };
				var success = validator.form();
                var data = self.getParam();

				if (success ){
					_save(data);
				}else{
                    $submit.attr('disabled',false);
                    $submit.html('提交');
                }

            });

            $type.change(function(){
                //新收录
                if($(this).val() == 12){
                    $include.css('display','block');
                }else{
                    $include.css('display','none');
                };
            });


        },

        getValidator: function() {
            var $container = this.options.$container;
            var $include = $container.find("#include");
            var $form = $container;
            if($include.css('display')=='none'){
                $include.find('input').val(0);
            }

            var validator = Validator.getValidator($form, Server.Config.validator);

            return validator;
        },

        getParam: function() {
            var $container = this.options.$container;
            var self = this;
			var checkboxObj = null;
            var $elements = $.makeArray($container.prop('elements')).filter(function(item) {

				return true;
            });

			var checkboxVal = [];
            var name;
            var key;
			var params = {};
            var flag = 0;

            $.each($elements, function() {
                name = this.name;
                if (name) {
                    if(name=='id' && $(this).val() == "") {

                    } else if(name =='idc'){
                        if(self.oldIdc!='' && self.oldIdc!= $(this).val()){
                            params['cluster'] = -1; //前后集群不一
                        }
                        params[name] = $(this).val();
                    }else {
                        params[name] = $(this).val().trim();
                    }
                }
            });


            return {entity : JSON.stringify(params) };
        },
        add: function(data) {
            this.dao.add(data, this.onSave);
        },
        edit: function(data) {
            this.dao.edit(data, this.onSave);
        },

        onSave: function(json) {
            var $submit = $('#Submit');
            setTimeout(function() {
                $submit.html('提交');
                $submit.attr('disabled',false);
            }, 750);
            if (json.code == 'A00000') {
                var html = '操作成功';
                $(document).tips({
                    content: html,
                    type: 'success',
                });
            } else {
                $(document).tips({
                    content: json.msg,
                    type: "error"
                });
            }

        },

    };

});

define('../server/Server.Version',['require','exports','module'],function(require, exports, module) {
    Server.Version = function(options) {
        this.dao = Server.Dao;
        this.options = $.extend(true, {}, options);

        this.util = Server.Util || {};
        this.config = Server.config || {};

    };

    Com.inherits(Server.Version, Ancestor.Grid).extend({
        cVersion:{},
        run: function(options, callback) {
            var self = this;
            var $container = self.options.$container;
            var gridConfig = self.getGridConfig(Server.Config.TABLE_zzdServer,Server.Config.TABLE_VERSION_COLMODEL_CONFIG);

            self.$grid = $container.find('table.grid');
            options = $.extend(true, {
                width: 1600,
                shrinkToFit: false,
                autowidth: false
            }, gridConfig, options);
            self.$grid.jqGrid(options);
            self.initMainVersion();

			self.perpareData();
            self.bindEvent();
        },

        initMainVersion: function(){
            var self = this;
            self.dao.versionHistory({},function(rdata){
                self.cVersion=self.versionList(rdata);
                self.initDialog();

                self.dao.getMainVersion({},function (rrdata) {
                    var vs = rrdata['data'].split(",");
                    var good = 1;
                    for(var i in vs){
                        if(vs[i]==""){
                            good = 0;
                            break;
                        }
                    }
                    if(good==1){
                        self.cVersion['mainVersion']=rrdata['data'].split(",");
                    }else{
                        self.cVersion['mainVersion']=self.cVersion['default']
                    }
                    Server.Util.difMainVersion(self.cVersion['mainVersion']);
                    Server.Util.showDialog(self.cVersion['mainVersion']);
                    Server.Util.closeDialog();
                });
            });
        },

        perpareData: function() {
            var self = this;
            var username = $("div.user a.name").html();
        },

        bindEvent: function() {
            var self = this;
            var $container = self.options.$container;
            var $mdiv = $("#mainVersionDiv");


            $container.find(".query-btn").on('click.query', function() {
                self.query(function(){
                    Server.Util.difMainVersion(self.cVersion['mainVersion']);
                });
                return false;
            });

            $container.find(".main-version").on('click', function() {
                Server.Util.showDialog(self.cVersion['mainVersion']);
            });

            $mdiv.find(".setMain").on('click', function() {
                var $btn=$(this);
                $btn.attr('disabled','disabled').html('提交中..');
                var versions = Server.Util.getNewMainVersion($mdiv);
                self.cVersion['mainVersion'] = versions.split(",");
                self.dao.setMainVersion({'versions':versions},function(){});
                self.dao.synVersionStatus({'versions':versions},function(){
                    self.query(function(){
                        Server.Util.difMainVersion(self.cVersion['mainVersion']);
                        Server.Util.closeDialog();
                        $btn.attr('disabled',false).html('设置');
                    });
                });
                return false;
            });

            $mdiv.find(".cancel").on('click', function() {
                $mdiv.dialog("close");
            });

        },


        versionList: function (rdata) {
            var info = [[],[],[],[],[],[],[]];
            var self = this;
            var resp = rdata['data'];
            var mainVersion = [];
            info[Server.Config.VERSION_IND['zzdVersion']] = resp[Server.Config.VERSION_IND['zzdVersion']].split(',').slice(0,-1);
            info[Server.Config.VERSION_IND['encoderVersion']] = resp[Server.Config.VERSION_IND['encoderVersion']].split(',').slice(0,-1);
            info[Server.Config.VERSION_IND['mergeToolVersion']] = resp[Server.Config.VERSION_IND['mergeToolVersion']].split(',').slice(0,-1);
            info[Server.Config.VERSION_IND['mergeServiceVersion']] = resp[Server.Config.VERSION_IND['mergeServiceVersion']].split(',').slice(0,-1);
            info[Server.Config.VERSION_IND['precisionCutToolVersion']] = resp[Server.Config.VERSION_IND['precisionCutToolVersion']].split(',').slice(0,-1);
            info[Server.Config.VERSION_IND['hardware']] = resp[Server.Config.VERSION_IND['hardware']].split(',').slice(0,-1);
            info[Server.Config.VERSION_IND['serverStatus']] = resp[Server.Config.VERSION_IND['serverStatus']].split(',');
            //info[Server.Config.VERSION_IND['versionStatus']] = resp[Server.Config.VERSION_IND['versionStatus']].split(',');
            
            for (var index in info){
                if(index == Server.Config.VERSION_IND['versionStatus']){
                    //Server.Util.statusList($('select').eq(index),info[index],Server.Config.VERSION_IND['versionStatus']);
                }else if(index == Server.Config.VERSION_IND['serverStatus']){
                    Server.Util.statusList($('select').eq(index),info[index],Server.Config.VERSION_IND['serverStatus']);
                }else{
                    Server.Util.versionHistory($('select').eq(index),info[index]);
                    mainVersion.push(info[index][0]);
                }
            }
            mainVersion.shift();
            info.shift();
            info.shift();
            info.shift();

            return {'versionHist':info,'default':mainVersion};
        },

        getParam: function(pageSize) {
            var self = this;
            var $container = self.options.$container;

            var $grid = self.$grid;
            var params = {};
            var $form = $container.find('form[name="basicFrm"]');

            var $elements = $.makeArray($form.prop('elements')).filter(function(item) {
                return true;
            });

            var checkboxVal = [];
            var name;
            var key;
            $.each($elements, function() {
                name = this.name;
                if (name) {
                    if($(this).val()){
                        params[name] = $.trim($(this).val());
                    }
                }
            });

            if(arguments.length==1){
                return {'paramsObj': JSON.stringify(params),'pageSize':pageSize}
            }

            return {'paramsObj': JSON.stringify(params)};
        },
        query: function(callback) {
            var self = this;
            var $container = self.options.$container;
            var $grid = self.$grid;
            self.overridePostData($grid);
            var params = self.getParam();
            $grid.jqGrid('setGridParam', {
                postData: params,
                gridComplete: function(){
                    callback.call(this);
                }
            }).trigger('reloadGrid', [{
                page: 1
            }]);
        },

        initDialog: function () {
            var self = this;
            $("#mainVersionDiv").dialog({
                title: "主版本设置",
                autoOpen: false,
                width: 400,
                modal: true,
                dialogClass: 'alert',
                resizable: false,
                open: function () {}
            });
            $("#mainVersionDiv").find('select').each(function (i,elem) {
                var v = self.cVersion['versionHist'][i];
                for(var index in v){
                    var node = $("<option>").val(v[index]).html(v[index]);
                    $(elem).append(node);
                }
            });
            $(".ui-dialog-titlebar-close").html('<span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">close</span>');
        },

    });

});

define('../server/Server.ClusterList',['require','exports','module'],function(require, exports, module) {
    Server.ClusterList = function(options) {
        this.dao = Server.Dao;
        this.options = $.extend(true, {}, options);
        this.util = Server.Util || {};
        this.config = Server.config || {};
    };

    Com.inherits(Server.ClusterList, Ancestor.Grid).extend({
        run: function(options, callback) {
            var self = this;
            var $container = self.options.$container;
            var gridConfig = self.getGridConfig(Server.Config.TABLE_SERVER_CLUSTER,Server.Config.TABLE_SERVER_CLUSTER_COLMODEL_CONFIG);

            self.$grid = $container.find('table.grid');
            //self.util.getClusterList($container);
            options = $.extend(true, {
                width: 1000,
                shrinkToFit: false,
                autowidth: false,
                subGrid:true,

                subGridRowExpanded: function(subgrid_id, row_id) {
                    var subgrid_table_id;
                    subgrid_table_id = subgrid_id + "_t";

                    var subgrid_pager_id;
                    subgrid_pager_id = subgrid_id + "_pgr"

                    // (5)动态添加子报表的table和pager
                    $("#" + subgrid_id).html("<table id='"+subgrid_table_id+"'class='scroll'></table></div>");

                    // (6)创建jqGrid对象
                    $("#" + subgrid_table_id).jqGrid({
                        url:"/api/sginal/server/clusterSeverList",  //(7)子表格数据对应的url，注意传入的contact.id参数
                        datatype: "json",

                        loadBeforeSend:function(xhr, settings){
                            var auth = self.util.getAuth("/sginal/server/clusterSeverList");
                            xhr.setRequestHeader('Sign',auth.sign);
                            xhr.setRequestHeader("Time",auth.clientTime);
                            xhr.setRequestHeader("From",auth.from);
                            return true;
                        },
                        postData:{'cluster':row_id},

                        colNames: ['IP','收录','最大收录'],
                        colModel: [
                            {name:"insideServerIp",index:"insideServerIp",width:150,sortable:false, align:'center'},
                            {name:"now_including",index:"now_including",width:150,sortable:false, align:'center'},
                            {name:"including",index:"including",width:150,sortable:'false', align:'center'},
                        ],
                        mtype: "post",
                        prmNames: {search: "search"},

                        height: "100%",
                        rowNum: 200,
                        width:700,
                        shrinkToFit: true
                    });
                },

            }, gridConfig, options);
            self.$grid.jqGrid(options);
			self.perpareData();
            self.bindEvent();
            self.initSuggest();
        },

        perpareData: function() {
            var self = this;
            var username = $("div.user a.name").html();
        },

        bindEvent: function() {
            var self = this;
            var $container = self.options.$container;
            var $search = $container.find('.search');
            var $new = $container.find('.edit');

            $search.on('click', function() {
                self.query();
            });

            $new.on('click', function() {
                window.open("edit_cluster.html");
            });
        },

        query: function() {
            var self = this;
            var $container = self.options.$container;
            var $grid = self.$grid;
            var param = self.getParam();
            $grid.jqGrid('setGridParam', {
                postData: param,
            }).trigger('reloadGrid', [{
                page: 1
            }]);
        },

        getParam:function(){
            var self = this;
            var $container = self.options.$container;
            var $input = $container.find('input');
            return {'clusterName':$input.val().trim()};
        },
        jumpFromHomePage: function(){
            var url = window.location.href;
            if(url.indexOf('?')==-1){
                return;
            }
            var id = url.split('?')[1];
           self.dao.clusterList({'id':id},function(rdata){
               var res = rdata['data'][result];
           });
        },

        initSuggest: function () {
            var self = this;
            var ClusterSuggest = {
                options: {
                    ajaxSettings: {
                        beforeSend: function (request) {
                            var authBase = Ancestor.Util.getAuth("/sginal/server/clusterList");
                            request.setRequestHeader('Sign', authBase.sign);
                            request.setRequestHeader("Time", authBase.clientTime);
                            request.setRequestHeader("From", authBase.from);
                            request.setRequestHeader("UserName", (auth.baseInfo.authInfo == null) ? "" : escape(auth.baseInfo.authInfo.userName).toLocaleLowerCase().replace(/%u/gi, '\\u'));
                        }
                    },
                    select: function (event, object) {
                        var obj = { "clusterName": Number(object.item.id) };
                        return true;
                    },
                    source: "/api/sginal/server/clusterList",
                    method: "post",
                    autoFilter: false,
                    autoFocus: false,
                    multiple: false,
                    parseValue: function () {
                        var val = this.element.val(),
                            ret = []
                        return ret;
                    },
                    getParam: function (term) {
                        return { "clusterName": $.trim(term) }
                    },
                    process: function (json) {
                        var ret = [],
                            self = this,
                            options = self.options,
                            itemData = null;
                        var data = null;
                        if (json == null) {
                            return [];
                        }
                        if (json.code === "A00000") {
                            data = json.data == null ? null : json.data;
                        }
                        if (!data) {
                            return [];
                        }
                        $.map(data.result, function (item) {
                            itemData = {};
                            itemData[options.valueKey] = item["id"];
                            itemData[options.labelKey] = item["name"]
                            ret.push(itemData);
                        });
                        return ret;
                    },
                    template: function (item) {
                        return item.label;
                    }
                }
            }
            ClusterSuggest.options.clearInvalid = false;
            $("input[name=clusterId]").suggest(ClusterSuggest.options);

        }

    });

});

define('../server/Server.ClusterEdit',['require','exports','module'],function(require, exports, module) {
    Server.ClusterEdit = function(options) {
        this.dao = Server.Dao;
        this.options = $.extend(true, {}, options);

        this.util = Server.Util || {};
        this.config = Server.config || {};

    };

    Com.inherits(Server.ClusterEdit, Ancestor.Grid).extend({
        run: function(options, callback) {
            var self = this;
            var $container = self.options.$container;
            var gridConfig = self.getGridConfig(Server.Config.TABLE_SERVER_IDCSERVER,Server.Config.TABLE_SERVER_IDCSERVER_COLMODEL_CONFIG);

            self.$grid = $container.find('table.grid');

            Server.Dao.clusterList({"pageSize":"300"},function(rdata){
                var names=[];
                var result = rdata['data']['result'];
                for(var i=0;i<result.length;i++){
                    names.push(result[i]['name']);
                }

                self.jumpFromHomePage(function(self,cluster){
                    self.setOptions(self,cluster);
                    var oldName = '';
                    if(cluster){
                        oldName = cluster['name'];
                    }

                    self.perpareData();
                    self.bindEvent(names,oldName);
                });

            });
        },

        perpareData: function() {
            var self = this;
            var username = $("div.user a.name").html();
        },

        bindEvent: function(names,oldName) {
            var self = this;
            var $container = self.options.$container;
            var $submit = $container.find('#Submit');
            var $cluserName = $container.find('input[name="name"]');
            var $idc = $container.find('select[name="idc"]');
            var $flag = $container.find('#flag');
            var validator = self.getValidator();
            var exists=1;
            if(oldName&&oldName!=''){
                exists = 0;
            }
            $idc.change(function() {
                self.query($(this).val());
            });

            $cluserName.on('input',function(){
                if(oldName == $(this).val()||names.indexOf($(this).val())==-1){
                    exists=0;
                    $flag.css('display','none');
                }else{
                    exists=1;
                    $flag.css('display','block');
                    $flag.css('color','red')
                }
            })

            $submit.on('click', function() {
                if(exists==0 || oldName==$cluserName.val()){
                    $submit.html('提交中..');
                    $submit.attr('disabled','disabled');
                    var _save = function(data) {
                        $submit.val('提交中..');
                        if ($('#id').val() != "") {
                            self.editCluster(data);
                        } else {
                            self.addCluster(data);
                        }
                    };

                    var success = validator.form();
                    var data = self.getParam();

                    if (success ){
                        _save(data);
                    }else{
                        $submit.attr('disabled',false);
                        $submit.html('提交');
                    }
                }
            });

        },

        getParam: function(pageSize) {
            var self = this;
            var $container = self.options.$container;

            var $grid = self.$grid;
            var params = {};

            var $elements = $.makeArray($container.prop('elements')).filter(function(item) {
                return true;
            });

            var ids='';
            var name;
            var key;
            $.each($elements, function() {
                name = this.name;
                if (name) {
                    if(name.substr(0,3)=='jqg'){
                        if(this.checked){
                            var id = name.substr(-4);
                            ids+=id+',';
                        }
                    }else{
                        if(name=='id' && $(this).val() == "") {

                        } else {
                            params[name] = $(this).val().trim();
                        }
                    }

                }
            });

            if(ids!=''){
                ids = ids.substr(0,ids.length-1);
                params['serverList'] = ids;
            }
            return params;
        },

        query: function(idc) {
            var self = this;
            var $container = self.options.$container;
            var $grid = self.$grid;
            self.overridePostData($grid);
            $grid.jqGrid('setGridParam', {
                postData: {'idc': idc},
            }).trigger('reloadGrid', [{
                page: 1
            }]);
        },

        getValidator: function() {
            var $container = this.options.$container;
            var $form = $container;
            var validator = Validator.getValidator($form, Server.Config.clusterValidator);

            return validator;
        },

        addCluster: function(data) {
            this.dao.addCluster(data, this.onSave);
        },

        editCluster: function(data) {
            this.dao.editCluster(data, this.onSave);
        },

        onSave: function(json) {
            var $submit = $('#Submit');
            setTimeout(function() {
                $submit.html('提交');
                $submit.attr('disabled',false);
            }, 750);
            if (json.code == 'A00000') {
                var html = '操作成功';
                $(document).tip({
                    content: html,
                    theme: 'success'
                });
                setTimeout(function() {
                    $(window).attr('location','cluster_home.html');
                }, 750);

            } else if(json.data == '-1111'){
                Server.Util.logTips({theme: "error", content: "正在收录任务，不可下线"});
            }else {
                Server.Util.logTips({theme: "error", content: "删除失败"});
            }
        },

        gridComplete: function($container){
            $container.find('tr').each(function(i,ele){
                if(i!=0){
                    if($(ele).find("[aria-describedby='IdcServerListGrid_cluster_name']").eq(0).html()!='未分配集群'){
                        $(ele).find('input').eq(0).attr('disabled',true);
                    };
                }
            });
        },

        jumpFromHomePage: function(callback){
            var url = window.location.href;
            var self = this;
            var $container = self.options.$container;
            if(url.indexOf('?')==-1){
                callback.call(this,self,undefined);
                return;
            }
            var ss = url.split('?')[1];
            var id = ss.split('=')[1];
            Server.Dao.clusterList({'clusterId':id},function(rdata){
                var res = rdata['data']['result'];
                if(res.length>0){
                    var cluster = res[0];
                    $container.find('input[name="name"]').val(cluster['name']);
                    $container.find('input[name="id"]').val(cluster['id']);
                    $container.find('select[name="status"]').val(cluster['status']);
                    $container.find('select[name="idc"]').attr('disabled',true).val(cluster['idc']);
                    callback.call(this,self,cluster);
                }
            });

        },

        setOptions: function(self,cluster){
            var $container = self.options.$container;
            var gridConfig = self.getGridConfig(Server.Config.TABLE_SERVER_IDCSERVER,Server.Config.TABLE_SERVER_IDCSERVER_COLMODEL_CONFIG);
            self.$grid = $container.find('table.grid');
            console.log(cluster);

            var idc ='-- -- -- --';
            var name = '*****';
            if(cluster){
                idc = cluster['idc'];
                name = cluster['name'];
            }

            var options = $.extend(true, {
                width: 370,
                shrinkToFit: false,
                autowidth: false,
                postData: {'idc': idc},
                gridComplete: self.gridComplete($container),
                onSelectAll:function(rowids,status){
                    $container.find('tr').each(function(i,ele){
                        if(i!=0){
                            var nn = $(ele).find("[aria-describedby='IdcServerListGrid_cluster_name']").html();
                            if(nn && nn !='待分配集群' && nn.indexOf(name)==-1){
                                $(ele).removeClass('ui-state-highlight');
                                $(ele).find('input').attr('checked',false);
                                $(ele).find('input').attr('disabled',true);
                            }
                        }
                    });
                },
                onSelectRow:function(rowids,status){
                    var tr = $(this).jqGrid("getInd",rowids,true);
                    var str = $(tr).html();
                    var len = $(tr).find(".assigned").size();
                    if(str.indexOf(name)!=-1){

                    }else if(len>0){
                        $(tr).removeClass('ui-state-highlight');
                        $(tr).removeClass('success');
                        $(tr).find('input').attr({
                            'checked':false,
                            'disabled':true
                        });
                    }
                },
                loadComplete:function(){
                    $container.find('tr').each(function(i,ele){
                        var str = $(ele).html();
                        if(str.indexOf(name)!=-1){
                            var id = $(ele).find('input').attr('id').substr(-4);
                            //console.log(id);
                            self.$grid.jqGrid("setSelection",id);
                        }else if($(ele).find(".assigned").size()>0){
                            $(ele).find('input').attr({
                                'checked':false,
                                'disabled':true
                            });
                        }

                    });
                }
            }, gridConfig, self.options);

            self.$grid.jqGrid(options);
        }
    });

});

define(
	'../sginal/Sginal',['require','exports','module'],function(require, exports, module){
		window.Sginal = window.Sginal || { version : '1.0' };
		//Video公共配置集合，键值对象
		Sginal.Config = Sginal.Config || {};
		Sginal.Util = Sginal.Util || {};

        Sginal.Constant = {
            devMode: auth.dev()
        }
	}
);
define(
	'../sginal/Sginal.Action',['require','exports','module'],function(require, exports, module){

        Sginal.Action = (function() {
			var sginalGrid = null;
            var getSginalGrid = function(options) {
                if (!sginalGrid) {

                    sginalGrid = new Sginal.Grid($.extend(true, {
                        '$container': $('#SginalListContainer'),
                        type: 0
                    }, options));
                }
                return sginalGrid;
            };
            var sginalGridRun = function(options) {
                sginalGrid = getSginalGrid(options);
                sginalGrid.run();
            };
			var run = function() {
                /* videoQueryRun();*/
                sginalGridRun({});
            };
            var editBase = null;
            var getEditBase = function(options) {

                if (!editBase) {
                    editBase = new Sginal.Edit(options);
                }
                return editBase;
            };
            var editRun = function() {
                var $container = $('.video-edit-form');
                getEditBase({
                    $container: $container
                }).run();
            };

            var sginalStatusBase = null;
            var getSginalStatusBase = function(options) {

                if (!sginalStatusBase) {
                    sginalStatusBase = new Sginal.Status(options);
                }
                return sginalStatusBase;
            };
            var sginalStatusRun = function() {
                var $container = $('#SignalStatusListContainer');
                getSginalStatusBase({
                    $container: $container
                }).run();
            };



            return {
                run: run,
				editRun:editRun,
                sginalStatusRun:sginalStatusRun,
				getSginalGrid:getSginalGrid,
            };
        })();
	}
);
define('../sginal/Sginal.Config',['require','exports','module'],function(require, exports, module) {

    Sginal.Config = $.extend({}, Ancestor.Config, {

        SGINAL_TYPE: ['udp', 'udi'],
        SGINAL_STATUS: ['未开启','开启', '停止'],
        SERVER_TYPE: ['收录', '编码', '分甘', '中继', '目的地'],
        PageBean: null,

        validator: {
            messages: {
                name: {
                    required: "频道名称不能为空",
                },
                accessServerIp: {
                    required: '信号接入服务器IP不能为空',
                },
                port: {
                    required: '信号传输统一端口不能为空',
                },
                inputType_2: {
                    required: '分甘输入类型不能为空',
                },
                inputIp_2: {
                    required: '分甘输入IP不能为空',
                },
                outputType_2: {
                    required: '分甘输出类型不能为空',
                },
                outputIp_2: {
                    required: '分甘输出IP不能为空',
                },
                outputType_4: {
                    required: '目的地类型不能为空',
                },
                outputIp_4: {
                    required: '目的地IP不能为空',
                }
            },

            rules: {
                name: {
                    required: true,
                },
                accessServerIp: {
                    required: true,
                },
                port: {
                    required: true,
                },
                inputType_2: {
                    required: true,
                },
                inputIp_2: {
                    required: true,
                },
                outputType_2: {
                    required: true,
                },
                outputIp_2: {
                    required: true,
                },
                outputType_4: {
                    required: true,
                },
                outputIp_4: {
                    required: true,
                }
            }
        },

			TABLE_COLMODEL_CONFIG: {
				'name': {
					name: 'name',
					title: false,
					index: 'name',
					align:'center',
					sortable: false,
					width: 100
				},
				'fgIp': {
                    name: 'fpIp',
                    title: false,
                    index: 'fpIp',
                    align:'center',
                    sortable: false,
                    width: 80
                },
                'fgPort': {
                    name: 'fgPort',
                    title: false,
                    index: 'fgPort',
                    align:'center',
                    sortable: false,
                    width: 100
                },
                'fgInputType': {
                    name: 'fgInputType',
                    title: false,
                    index: 'fgInputType',
                    align:'center',
                    sortable: false,
                    width: 100,
                    formatter: function(v, o, r) {
                        return Sginal.Util.formatter.sginalType(v,r);
                    }
                },
				'fgInputSrc': {
					name: 'fgInputSrc',
					title: false,
					index: 'fgInputSrc',
					align:'center',
					width: 100,
					sortable: false
				},
				'fgOutputType': {
					name: 'fgOutputType',
					title: false,
					index: 'fgOutputType',
					align:'center',
					sortable: false,
					width: 100,
					align: 'center',
                    formatter: function(v, o, r) {
                        return Sginal.Util.formatter.sginalType(v,r);
                    }
				},
				'fgOutputSrc': {
					name: 'fgOutputSrc',
					title: false,
					index: 'fgOutputSrc',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'fgStatus': {
					name: 'fgStatus',
					title: false,
					index: 'fgStatus',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center',
                    formatter: function(v, o, r) {
                        return Sginal.Util.formatter.sginalStatus(v,r);
                    }
				},
				'fgStatusArgs': {
					name: 'fgStatusArgs',
					title: false,
					index: 'fgStatusArgs',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'idcIp': {
					name: 'idcIp',
					title: false,
					index: 'idcIp',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'idcPort': {
					name: 'idcPort',
					title: false,
					index: 'idcPort',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'idcOutputType': {
					name: 'idcOutputType',
					title: false,
					index: 'idcOutputType',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center',
                   formatter: function(v, o, r) {
                       return Sginal.Util.formatter.sginalType(v,r);
                   }
				},
				'idcOutputSrc': {
					name: 'idcOutputSrc',
					title: false,
					index: 'idcOutputSrc',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'idcStatus': {
					name: 'idcStatus',
					title: false,
					index: 'idcStatus',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center',
                    formatter: function(v, o, r) {
                        return Sginal.Util.formatter.sginalStatus(v,r);
                    }
				},
				'idcStatusArgs': {
					name: 'idcStatusArgs',
					title: false,
					index: 'idcStatusArgs',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'author': {
					name: 'author',
					title: false,
					index: 'author',
					align:'center',
					width: 100,
					sortable: false,
					align: 'center'
				},
				'operate': {
                    name: 'operate',
                    title: false,
                    index: 'operate',
                    width: 160,
                    align:'center',
                    sortable: false,
                    formatter: function(v, o, r) {
                        return Sginal.Util.formatter.operate(v,r);
                    }
                },
///
                'serverIp': {
                    name: 'serverIp',
                    title: false,
                    index: 'serverIp',
                    align:'center',
                    width: 50,
                    sortable: false,
                    align: 'center'
                },
                'statusArgs': {
                    name: 'statusArgs',
                    title: false,
                    index: 'statusArgs',
                    align:'center',
                    width: 300,
                    sortable: false,
                    align: 'center'
                },
                'addTime': {
                    name: 'addTime',
                    title: false,
                    index: 'addTime',
                    align:'center',
                    width: 100,
                    sortable: false,
                    align: 'center',
                    formatter: function(v, o, r) {
                        return Sginal.Util.formatter.time(v,r);
                    }
                },
                'user': {
                    name: 'user',
                    title: false,
                    index: 'user',
                    align:'center',
                    width: 60,
                    sortable: false,
                    align: 'center'
                },
                'action': {
                    name: 'action',
                    title: false,
                    index: 'action',
                    align:'center',
                    width: 60,
                    sortable: false,
                    align: 'center'
                },
                'descr': {
                    name: 'descr',
                    title: false,
                    index: 'descr',
                    align:'center',
                    width: 300,
                    sortable: false,
                    align: 'center'
                }

			},

			TABLE: {
			    url: "/api/sginal/list",
			    rowNum: 10,
                pager: "#SginalListPager",
			    multiselect: false,
			    prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

			    loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth(Ancestor.Config.EPG_AUTH.list);
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

			    //datatype: "local",
			    loadtext: '加载中...',
                loadui: "block",
                mtype: "post",

				colNames: ["信号名称", "分甘点IP", "分甘点端口", "分甘点输入类型", "分甘点输入地址 ", "分甘点输出类型", "分甘点输出地址", "分甘点状态", "分甘点数据", "IDC服务器IP", "IDC服务器端口", "IDC输出类型", "IDC输出地址", "IDC状态", "IDC数据", "操作人", "操作", "详情"],
				colModel: ['name', 'fgIp', 'fgPort', 'fgInputType', 'fgInputSrc', 'fgOutputType', 'fgOutputSrc', 'fgStatus', 'fgStatusArgs', 'idcIp', 'idcPort', 'idcOutputType', 'idcOutputSrc', 'idcStatus', 'idcStatusArgs', 'author', 'operate', 'details']
			},
            TABLE_STATUS_COLMODEL_CONFIG: {
                'fatherId': {
                    name: 'fatherId',
                    title: false,
                    index: 'fatherId',
                    align:'center',
                    sortable: false,
                    width: 120
                },
                'name': {
                    name: 'name',
                    title: false,
                    index: 'name',
                    align:'center',
                    sortable: false,
                    width: 120
                },
                'serverIp': {
                    name: 'serverIp',
                    title: false,
                    index: 'serverIp',
                    align:'center',
                    sortable: false,
                    width: 120
                },
                'statusArgs': {
                    name: 'statusArgs',
                    title: false,
                    index: 'statusArgs',
                    align:'left',
                    sortable: false,
                    width: 1200
                },
                'addTime': {
                    name: 'addTime',
                    title: false,
                    index: 'addTime',
                    align:'center',
                    sortable: false,
                    width: 150
                }
            },

            TABLE_STATUS: {
                url: "/api/sginal/status/list",
                rowNum: 20,
                pager: "#status_pager",
                multiselect: false,
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

                loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/sginal/status/list");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

                //datatype: "local",
                loadtext: '加载中...',
                loadui: "block",
                mtype: "post",

                colNames: ["频道ID","频道名称","服务器IP", "投递状态", "添加时间"],
                colModel: ['fatherId','name','serverIp', 'statusArgs', 'addTime']
            },

            TABLE_LOG: {
                url: "/api/sginal/log",
                rowNum: 10,
                pager: "#log_pager",
                multiselect: false,
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },

                loadBeforeSend:function(xhr, settings){
                    var auth = Ancestor.Util.getAuth("/sginal/log");
                    xhr.setRequestHeader('Sign',auth.sign);
                    xhr.setRequestHeader("Time",auth.clientTime);
                    xhr.setRequestHeader("From",auth.from);
                    return true;
                },

                //datatype: "local",
                loadtext: '加载中...',
                loadui: "block",
                mtype: "post",

                colNames: ["操作时间", "人员", "动作", "备注"],
                colModel: ['addTime', 'user', 'action', 'descr']
            },
		});
});
define(
	'../sginal/Sginal.Dao',['require','exports','module'],function(require, exports, module){

        Sginal.Dao = $.extend({}, Ancestor.Dao, {
            getList: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/list",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/list");
            },
            getStatusList: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/status/list",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/list");
            },
            add: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/create",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/create");
            },
            edit: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/edit",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/edit");
            },
            delete: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/delete",
                    dataType: "json",
                    data: data,
                    forceDel: function(rdata){
                        if(rdata.code!="A00000"){
                            SystemDialog.queryConfirm("删除失败，是否要强制删除？", function (flag) {
                                if (flag == true) {
                                    Sginal.Dao.forceDel(data, function () {
                                        $('.query-btn').click();
                                    });
                                }
                            });
                        }
                    },
                    success: function (rdata) {
                        callback.call(this, rdata);
                        this.forceDel(rdata);

                    },
                    error: function (rdata) {
                        callback.call(this, rdata);
                        this.forceDel(rdata);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/delete");
            },
            forceDel: function(data, callback){
                var options = {
                    type: "post",
                    url: "/api/sginal/forceDel",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/forceDel");
            },
            start: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/start",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/start");
            },
            stop: function (data, callback) {
                var options = {
                    type: "post",
                    url: "/api/sginal/stop",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                }
                Ancestor.Dao.ajax(options, "/sginal/stop");
            },
            redirect: function(data, callback) {
                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options,'/redirect');
            }

        });
	}
);
define('../sginal/Sginal.Util',['require','exports','module'],function(require, exports, module) {
	Sginal.Util = $.extend(true, {}, Ancestor.Util, {
			formatter: {
			    sginalType: function (v, r) {
                    return Sginal.Config.SGINAL_TYPE[v];
                },
                sginalStatus: function (v, r) {
                    return Sginal.Config.SGINAL_STATUS[v];
                },
                serverType: function (v, r) {
                    return Sginal.Config.SERVER_TYPE[v];
                },
                time: function (v, r) {
                    return v.substring(0, 19);
                },
                operate:function(v,r) {
                    var str = "";
                    if (r.status == 0 || r.status == 2) {
                        str += "<a href='/epg/sginal_edit.html?id=" + r.id + "' class='btn btn-info' target='_blank'>修改</a>";
                        str += " <a href='javascript:void(0);' onclick='Sginal.Util.start(" + r.id + ")' class='btn btn-success' style='display:inline' target='_blank'>开启</a>";
                        str += "<a href='javascript:void(0);' onclick='Sginal.Util.stop(" + r.id + ")' class='btn btn-warning' style='display:none' target='_blank'>停止</a>";
                        str += " <a href='javascript:void(0);' onclick='Sginal.Util.del(" + r.id + ")' class='btn btn-danger' target='_blank'>删除</a>";
                    } else {
                        str += "<a href='javascript:void(0)' class='btn btn-info' target='_blank' disabled='disabled'>修改</a>";
                        str += " <a href='javascript:void(0);' onclick='Sginal.Util.start(" + r.id + ")' class='btn btn-success' style='display:none' target='_blank'>开启</a>";
                        str += "<a href='javascript:void(0);' onclick='Sginal.Util.stop(" + r.id + ")' class='btn btn-warning' style='display:inline' target='_blank'>停止</a>";
                        str += " <a href='javascript:void(0);' onclick='Sginal.Util.del(" + r.id + ")' class='btn btn-danger' target='_blank'>删除</a>";
                    }
                    str += " <a href='javascript:void(0);' data-id='" + r.id + "' onclick='Sginal.Util.sginalLogList(this);' class='btn btn-link'>详细</a>";
                    return str;
                }

            },

            del: function(id){
                var self = this;
                // if(window.confirm('是否从列表中删除该数据？')) {
                //     var params = {id : id};
                //     Sginal.Dao.delete(params, function(){
                //         $('.query-btn').click();
                //     });
                //     return true;
                // }

                SystemDialog.queryConfirm("是否从列表中删除该数据？", function (flag) {
                    if (flag == true) {
                        var params = {id : id};
                        Sginal.Dao.delete(params, function(){
                            $('.query-btn').click();
                        });
                    }
                    return true;
                });
            },

            start: function(id){
                var self = this;
                var params = {id : id};
                Sginal.Dao.start(params, function(data){
                    $('.pageClick').click();
                });
                return true;
            },
            stop: function(id){
                var self = this;
                var params = {id : id};
                Sginal.Dao.stop(params, function(data){
                    $('.pageClick').click();
                });
                return true;
            },
            getList: function(pn) {
                $("input[name=pageNo]").val(pn);
                $('.pageClick').click();
            },

            statusList: function(obj) {
                var self = this;
                var id = $(obj).attr('data-id');
                var serverIp = $(obj).attr('data-serverIp');
                var params = {fatherId: id, serverIp: serverIp};

                $('#statusList').jqGrid('setGridParam', {
                    page: 1,
                    datatype: "json",
                    postData: params
                }).trigger('reloadGrid');
                self.openDlg($("#o-h-dlg"), '服务器状态',900 , 600);
            },

            sginalLogList: function(obj) {
                var self = this;
                var fatherId = $(obj).attr('data-id');
                var params = {fatherId: fatherId};

                $('#sginalLogList').jqGrid('setGridParam', {
                    page: 1,
                    datatype: "json",
                    postData: params
                }).trigger('reloadGrid');
                self.openDlg($("#o-h-slog"), '历史记录',900 , 600);
            },

            calculateDate: function (str) {//month 7days yestoday today
                var from_date = "", to_date = "";
                var d = new Date();
                var defaultEnd = this.formatDateTimeFormat(d);
                this.setZeroTime(d);
                if (str == "today") {
                    from_date = this.formatDateTimeFormat(d);
                    to_date = defaultEnd;
                }
                if (str == "yesterday") {
                    d.setDate(d.getDate() - 1);
                    from_date = this.formatDateTimeFormat(d);
                    this.setDayLastTime(d);
                    to_date = this.formatDateTimeFormat(d);
                }

                if (str == "7days") {
                    d.setDate(d.getDate() - 6);
                    from_date = this.formatDateTimeFormat(d);
                    to_date = defaultEnd
                }
                if (str == "month") {
                    d.setMonth(d.getMonth() - 1);
                    from_date = this.formatDateTimeFormat(d);
                    to_date = defaultEnd
                }
                if (str == "absToday") {
                    from_date = this.formatDateTimeFormat(d);
                    this.setDayLastTime(d);
                    to_date = this.formatDateTimeFormat(d);
                }

                if (str == "absToday+") {
                    this.setZeroTime(d);
                    d.setHours(10);
                    from_date = this.formatDateTimeFormat(d);
                    d.setDate(d.getDate() + 1);
                    to_date = this.formatDateTimeFormat(d);
                }

                this.bindDate("startDate", "endDate", { maxDate: to_date, maxDateTime: new Date(to_date.replace(/-/g, "/")), minDate: from_date, minDateTime: new Date(from_date.replace(/-/g, "/"))})
                $("input[name=startDate]").datetimepicker("setDate", new Date(from_date.replace(/-/g, "/")));
                $("input[name=endDate]").datetimepicker("setDate", new Date(to_date.replace(/-/g, "/")));
            },
            formatDateTimeFormat: function (myDate) {
                var year = myDate.getFullYear();
                var month = ("0" + (myDate.getMonth() + 1)).slice(-2);
                var day = ("0" + myDate.getDate()).slice(-2);
                var h = ("0" + myDate.getHours()).slice(-2);
                var m = ("0" + myDate.getMinutes()).slice(-2);
                var s = ("0" + myDate.getSeconds()).slice(-2);
                return year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s;
            },
            setZeroTime: function (checkTime) {
                checkTime.setSeconds(0);
                checkTime.setMinutes(0);
                checkTime.setHours(0);
                checkTime.setMilliseconds(0);
            },
            bindDate: function (nameMin, nameMax, plusData) {
                var options1 = {
                    sliderAccessArgs: { touchonly: false },
                    onClose: function (selectedDate) {
                        console.log("bindDate " +  selectedDate )
                        $("input[name=" + nameMax + "]").datetimepicker("option", "minDate", selectedDate);
                        var toDate = new Date(selectedDate.replace(/-/g, "/"))
                        $("input[name=" + nameMax + "]").datetimepicker("option", "minDateTime", toDate);
                    }
                }
                var options2 = {
                    sliderAccessArgs: { touchonly: false },
                    onClose: function (selectedDate) {
                        console.log("bindDate " +  selectedDate )
                        $("input[name=" + nameMin + "]").datetimepicker("option", "maxDate", selectedDate);
                        var toDate = new Date(selectedDate.replace(/-/g, "/"))
                        $("input[name=" + nameMin + "]").datetimepicker("option", "maxDateTime", toDate);
                    }
                }
                if (plusData != null && plusData.hasOwnProperty("slider")) {
                    options1.controlType = "slider";
                    options2.controlType = "slider";
                }
                $("input[name=" + nameMin + "]").datetimepicker(options1)
                $("input[name=" + nameMax + "]").datetimepicker(options2)
                if (plusData != null) {
                    $("input[name=" + nameMin + "]").datetimepicker("option", "maxDate", plusData.maxDate);
                    $("input[name=" + nameMin + "]").datetimepicker("option", "maxDateTime", plusData.maxDateTime);
                    $("input[name=" + nameMax + "]").datetimepicker("option", "minDate", plusData.minDate);
                    $("input[name=" + nameMax + "]").datetimepicker("option", "minDateTime", plusData.minDateTime);
                }
            },
            setDayLastTime: function (checkTime) {
                checkTime.setSeconds(59);
                checkTime.setMinutes(59);
                checkTime.setHours(23);
                checkTime.setMilliseconds(0);
            },
    });
});
define(
    '../sginal/Sginal.Grid',['require','exports','module'],function(require, exports, module) {

        Sginal.Grid = function(options) {
            this.dao = Sginal.Dao;
            this.config = Sginal.Config;
            this.util = Sginal.Util;
            this.options = options || {};

			//this.channel_id = Com.url.getQueryValue("channel_id",location.href);
			//this.channel_name = Com.url.getQueryValue("channel_name",location.href);
            this.construct = options.construct || function() {
                this.init();
            };
            this.construct.call(this);
        };

        Com.inherits(Sginal.Grid, Ancestor.Grid).extend({
            init: function() {
                var self = this;
                var $container = self.options.$container;
                self.$grid = $container.find('table.grid');
                self.perpareData();
                self.bindBasicEvent();
                self.initSuggest();
                self.query();
            },

            perpareData: function() {
                var self = this;
                var username = $("div.user a.name").html();
            },

            bindBasicEvent: function() {
                var self = this;

                var $container = self.options.$container;

                $container.find('.query-add').click(function() {
					window.open("/epg/sginal_edit.html");
                });
                

                $container.find('.query-btn').on('click.query', function() {
                    $('input[name=pageNo]').val(1);
                    self.query();
                    return false;
                });

                $container.find('.pageClick').on('click.query', function() {
                    self.query();
                    return false;
                });

                $container.find('.server-home').click(function() {
                    window.open("/epg/server_home.html");
                });
			},

			bindFormEvent: function($form) {
                var self = this;

			},

            run: function(options, callback) {
                var self = this;
                var colModelConfig = Sginal.Config.TABLE_COLMODEL_CONFIG;

                var tableConfig = $.extend(true, {}, Sginal.Config.TABLE_STATUS );
                tableConfig.width =  875;
                var colModel = tableConfig.colModel;
                var newColModel = [];

                $.each(colModel, function(i, model) {
                    newColModel.push(colModelConfig[model]);
                });
                tableConfig.colModel = newColModel;
                //$('#statusList').jqGrid(tableConfig);

                tableConfig = $.extend(true, {}, Sginal.Config.TABLE_LOG );
                tableConfig.width =  875;
                var colModel = tableConfig.colModel;
                var newColModel = [];

                $.each(colModel, function(i, model) {
                    newColModel.push(colModelConfig[model]);
                });
                tableConfig.colModel = newColModel;
                $('#sginalLogList').jqGrid(tableConfig);
            },

            getParam: function() {
                var self = this;
                var $container = self.options.$container;

                var $grid = self.$grid;
                var params = {};
                var $form = $container.find('form[name="basicFrm"]');

                var $elements = $.makeArray($form.prop('elements')).filter(function(item) {
					return true;
                });

				var checkboxVal = [];
                var name;
                var key;
                $.each($elements, function() {
                    name = this.name;
                    if (name) {
                        if($(this).val()){
                            params[name] = $.trim($(this).val());
                        }
                    }

                });
                var id = Com.url.getQueryValue("id",location.href);
                if (id != null) {
                    params["id"] = id;
                    id = null;
                }
                return params;
            },

            query: function() {
                var self = this;

                var params = self.getParam();
                var pn = parseInt(params['pageNo']);
                Sginal.Dao.getList(params, function(data){
                    if (data != null && data.code=="A00000" && data.data.result != null) {
                        var sginals = data.data.result;
                        var gridDatas = "";
                        $.each(sginals, function (n, sginal) {
                            gridDatas += '<div class="MenuPanel row "><div class="MenuTitle"><ul>';
                            gridDatas += '<li class="smallC slide">' + sginal.id + '</li>';
                            gridDatas += '<li class="bigC slide">' + sginal.name + '</li>';
                            gridDatas += '<li class="smallC slide">' + sginal.port + '</li>';
                            gridDatas += '<li class="smallC slide">' + Sginal.Util.formatter.sginalStatus(sginal.status, '') + '</li>';
                            gridDatas += '<li class="smallC slide">' + sginal.author + '</li>';
                            gridDatas += '<li class="largeC slide" style="width: 20%">' + Sginal.Util.formatter.operate('', sginal) + '</li></ul></div>';
                            gridDatas += '<div class="MenuContent"><table class="table table-hover"><thead><tr>';
                            gridDatas += '<th>接入服务器IP<th>';
                            gridDatas += '<th>信号输入类型<th>';
                            gridDatas += '<th>信号输入IP<th>';
                            gridDatas += '<th>信号输出类型<th>';
                            gridDatas += '<th>信号输出IP<th>';
                            gridDatas += '<th>网卡号<th>';
                            gridDatas += '<th>服务器类型<th></tr></thead><tbody>';
                            $.each(sginal.sginalServers, function (n, sginalServer) {
                                gridDatas += '<tr>';
                                gridDatas += '<td>' + sginalServer.interfaceIp + '<td>';
                                gridDatas += '<td>' + Sginal.Util.formatter.sginalType(sginalServer.inputType, '') + '<td>';
                                gridDatas += '<td>' + sginalServer.inputIp + '<td>';
                                gridDatas += '<td>' + Sginal.Util.formatter.sginalType(sginalServer.outputType, '') + '<td>';
                                gridDatas += '<td>' + sginalServer.outputIp + '<td>';
                                if (typeof(sginalServer.ethNum)!='undefined') {
                                    gridDatas += '<td>' + sginalServer.ethNum + '<td>';
                                } else {
                                    gridDatas += '<td>无<td>';
                                }
                                gridDatas += '<td>' + Sginal.Util.formatter.serverType(sginalServer.serverType, '') + '<td>';
                                gridDatas += '<td><a target="_blank" href="signal_status.html?fatherId='+sginal.id+'&serverIp='+sginalServer.interfaceIp+'&name='+encodeURI(sginal.name)+'">状态</a><td>';
                                gridDatas += '</tr>';
                            });
                            gridDatas += '</tbody></table></div></div>';
                        });
                        $('.panel-body').html(gridDatas);

                        var dataCount=data.data.totalCount; //总数据条数
                          var pageSize=data.data.pageSize;//每页显示条数
                          var pageCount= Math.ceil(dataCount / pageSize);//总页数
                          if(pn==0||pn>pageCount){
                            return;
                          }
                          var ul=$(".listul");
                          ul.empty();
                          self.paintPage(pageCount,pn);   //绘制页码

                        $(".MenuPanel").each(function(){
                            $(this).children(".MenuContent").hide();
                        });

                        $(".MenuTitle ul .slide").each(function(){
                            $(this).click(function(){

                                if($(this).parents(".MenuPanel").children(".MenuContent").css("display") != "none"){
                                   $(this).parents(".MenuPanel").children(".MenuContent").slideUp("fast");
                                }else{
                                    $(this).parents(".MenuPanel").children(".MenuContent").slideDown("fast");
                                }
                            });

                        });
                        return true;
                    }
                });
            },

            paintPage: function(number, currNum) {//number 总页数,currNum 当前页
                var self = this;
                var pageUl=$(".fenye");
                    pageUl.empty();
                    var ulDetail="";

                    if(number==1){
                     ulDetail= "<li class=\"prev\"><a href=\"javascript:void(0)\">上一页</a></li>"+
                     "<li class=\"numb choose\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(1)'>1</a></li>"+
                     "<li class=\"next\"><a href=\"javascript:void(0)\">下一页</a></li>";
                   }else if(number==2){
                     ulDetail= "<li class=\"prev\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(1)'>上一页</a></li>"+
                     "<li class=\"numb"+self.choosele(currNum,1)+"\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(1)'>1</a></li>"+
                     "<li class=\"numb"+self.choosele(currNum,2)+"\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(2)'>2</a></li>"+
                     "<li class=\"next\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(2)'>下一页</a></li>";
                   }else if(number==3){
                     ulDetail= "<li class=\"prev\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum-1) + ")'>上一页</a></li>"+
                     "<li class=\"numb"+self.choosele(currNum,1)+"\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(1)'>1</a></li>"+
                     "<li class=\"numb"+self.choosele(currNum,2)+"\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(2)'>2</a></li>"+
                     "<li class=\"numb"+self.choosele(currNum,3)+"\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(3)'>3</a></li>"+
                     "<li class=\"next\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum+1) + ")'>下一页</a></li>";
                   }else if(number==currNum&&currNum>3){
                     ulDetail= "<li class=\"prev\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum-1) + ")'>上一页</a></li>"+
                     "<li class=\"numb\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum-2) + ")'>"+parseInt(currNum-2)+"</a></li>"+
                     "<li class=\"numb\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum-1) + ")'>"+parseInt(currNum-1)+"</a></li>"+
                     "<li class=\"numb choose\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + currNum + ")'>"+currNum+"</a></li>"+
                     "<li class=\"next\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + currNum + ")'>下一页</a></li>";
                   }else if(currNum==1&&number>3){
                     ulDetail= "<li class=\"prev\"><a href=\"javascript:void(0)\">上一页</a></li>"+
                     "<li class=\"numb choose\"><a href=\"javascript:void(0)\">1</a></li>"+
                     "<li class=\"numb\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(2)'>2</a></li>"+
                     "<li class=\"numb\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(3)'>3</a></li>"+
                     "<li class=\"next\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(2)'>下一页</a></li>";
                   }else{
                     ulDetail= "<li class=\"prev\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum-1) + ")'>上一页</a></li>"+
                     "<li class=\"numb\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum-1) + ")'>"+parseInt(currNum-1)+"</a></li>"+
                     "<li class=\"numb choose\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + currNum + ")'>"+currNum+"</a></li>"+
                     "<li class=\"numb\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum+1) + ")'>"+parseInt(currNum+1)+"</a></li>"+
                     "<li class=\"next\"><a href='javascript:void(0);' onclick='Sginal.Util.getList(" + parseInt(currNum+1) + ")'>下一页</a></li>";
                   }

                   $(".fenye").append(ulDetail);
            },

            choosele: function(num,cur) {
                    if(num==cur){
                        return " choose";
                    }else{
                        return "";
                    }
            },


            initSuggest: function() {
                var serverIpSuggest = {
                    options: {
                        source: "/api/server/list",
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            var val = this.element.val(),
                                ret = []
                            return ret;
                        },
                        getParam: function (term) {
                            var requestData = {serverIp: term,status: 1,server_type: 2, timeSign: new Date().getTime()};
                            return requestData;
                        },

                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data.result;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["id"];
                                itemData[options.labelKey] = item["serverIp"];
                                itemData["serverIp"] = item["serverIp"];
                                itemData["serverPort"] = item["serverPort"];
                                itemData["province"] = item["province"] || "";
                                itemData["city"] = item["city"] || "";
                                itemData["remark"] = item["remark"];
                                ret.push(itemData);
                            });
                            return ret;
                        },

                        template: function (item) {
                            var formatArr = [];
                            formatArr.push('<span class="contract-width100">' + item["serverIp"] + '</span>');
                            formatArr.push('<span class="contract-width100">' + item["serverPort"] + '</span>');
                            formatArr.push('<span class="contract-width80">' + item["province"] + '</span>');
                            formatArr.push('<span class="contract-width80">' + item["city"] + '</span>');
                            formatArr.push('<span class="contract-width300">' + item["remark"] + '</span>');
                            return '<div class="contract-item" >' + formatArr.join("") + '</div>';
                        },
                        header: '<div class="contract-item" >' +
                            '<span class="contract-width100">服务器IP</span>' +
                            '<span class="contract-width100">服务器端口号</span>' +
                            '<span class="contract-width80">省份</span>' +
                            '<span class="contract-width80">市区</span>' +
                            '<span class="contract-width300">描述</span>'
                    }
                };

                //$("input[name=fgIp]").suggest(serverIpSuggest.options);
                //$("input[name=idcIp]").suggest(serverIpSuggest.options);
            }
        });

    }
);
define('../sginal/Sginal.Edit',['require','exports','module'],function(require, exports, module) {
    Sginal.Edit = function(options) {
        this.dao = Sginal.Dao;
        this.options = $.extend(true, {}, options);

        this.util = Sginal.Util || {};
        this.config = Sginal.config || {};
    };

    Sginal.Edit.prototype = {
        initConfig: function() {
			return true;
		},
        init: function() {
        },

        run: function() {
            var self = this;
            var $container = self.options.$container;
            self.init();
            self.initConfig();

			self.bindEvent();
			self.perpareData();
            self.fillForm();
            self.initSuggest();
        },

        perpareData: function() {
            var self = this;
            var username = $("div.user a.name").html();
        },

        fillForm: function () {
            var id = Sginal.Util.getUrlId("id");
            var self = this;
            if (id != null) {
                self.dao.getList({id: id}, function (data) {
                    var retValue = null;
                    if (data.code === "A00000" && data.data.result != null) {
                        retValue = data.data.result[0];
                        self.fillData(retValue);
                    } else {
                        self.fillNoData();
                    }
                });
            } else {
                self.fillNoData();
            }
        },

        fillData: function (element) {
            var self = this;
            for (var sginalBaseKey in element) {
                if (sginalBaseKey =="sginalServers") {
                    var sginalServer = element[sginalBaseKey];
                    $.each(sginalServer, function (n, value) {
                        if (value.serverType == 2) {
                            self.options.$container.find("input[name=id_" + value.serverType + "]").val(value.id);
                            self.options.$container.find("select[name=inputType_" + value.serverType + "]").val(value.inputType);
                            self.options.$container.find("input[name=inputIp_" + value.serverType + "]").val(value.inputIp);
                            self.options.$container.find("input[name=inputPort_" + value.serverType + "]").val(value.port);
                            self.options.$container.find("select[name=outputType_" + value.serverType + "]").val(value.outputType);
                            self.options.$container.find("input[name=outputIp_" + value.serverType + "]").val(value.outputIp);
                            self.options.$container.find("input[name=outputPort_" + value.serverType + "]").val(value.port);
                        } else if (value.serverType == 3) {
                            var $addndel = $("#addndel");
                            var $addBtn = $addndel.find("button[class='btn add blue-btn']");
                            if (value.sequence == 1) {
                            } else {
                                $addBtn.click();
                                $addBtn = $addndel.find("button[class='btn add blue-btn']");
                            }
                            $addBtn.parents(".form-group").find("input[name=id_" + value.serverType + "]").val(value.id);
                            $addBtn.parents(".form-group").find("select[name=outputType_" + value.serverType + "]").val(value.outputType);
                            $addBtn.parents(".form-group").find("input[name=outputIp_" + value.serverType + "]").val(value.outputIp);
                            $addBtn.parents(".form-group").find("input[name=outputPort_" + value.serverType + "]").val(value.port);
                        } else if (value.serverType == 4) {
                            self.options.$container.find("input[name=id_" + value.serverType + "]").val(value.id);
                            self.options.$container.find("select[name=outputType_" + value.serverType + "]").val(value.outputType);
                            self.options.$container.find("input[name=outputIp_" + value.serverType + "]").val(value.outputIp);
                            self.options.$container.find("input[name=outputPort_" + value.serverType + "]").val(value.port);
                            self.options.$container.find("select[name=ethNum_4]").val(value.ethNum);
                        }
                    });
                } else if (sginalBaseKey == "id"){
                    self.options.$container.find("input[name=sginalBaseId]").val(element[sginalBaseKey]);
                } else {
                    self.options.$container.find("input[name=" + sginalBaseKey + "]").val(element[sginalBaseKey]);
                }
            }
            $("input[name^=inputPort]").val(element["port"]);
            $("input[name^=outputPort]").val(element["port"]);
        },
        fillNoData: function () {
            var self = this;
        },

        bindEvent: function() {
            var self = this;
            var validator = self.getValidator();
            var $container = self.options.$container;
            var $submit = $container.find('#Submit');

            $container.find('input[name=port]').change(function() {
                $("input[name^=inputPort]").val($(this).val());
                $("input[name^=outputPort]").val($(this).val());
            });

            $addndel = $('#addndel').addndel({
                rowClass : 'form-group',
                addDecorator : function($newRow, $clickedRow) {
                    var order = $clickedRow.attr("order");
                    $newRow.attr("order", parseInt(order) + 1);
                    $newRow.find("input[name=outputPort_3]").val($("input[name=port]").val());
                    return true;
                },
                delDecorator : function($deletedRow) {
                  return true;
                }
              });

            $submit.on('click', function() {
                var _save = function(data) {
                    $(document).tips({
                        content: "页面提交中",
                        type: "loading"
                    });
                    if ($('#sginalBaseId').val() != "") {
                        self.edit(data);
                    } else {
                        self.add(data);
                    }
                };
				var success = validator.form();
                var data = self.getParam();

				if (success){
					_save(data);
				}

            });
        },

        getValidator: function() {
            var $container = this.options.$container;
            var $form = $container;
            var validator = Validator.getValidator($form, Sginal.Config.validator);

            return validator;
        },
        getParam: function() {
            var $container = this.options.$container;
            var self = this;
			var checkboxObj = null;
            var $elements = $.makeArray($container.prop('elements')).filter(function(item) {

				return true;
            });

			var checkboxVal = [];
            var name;
            var key;
			var params = {};
			var sginalServers = [];
            var server ={};
            var order = -1;
            var num = 0;
            $.each($elements, function() {
                name = this.name;
                if (name) {
                    if(name=='sginalBaseId' && $(this).val() != '') {
                        params['id'] = $(this).val();
                    } else if (name=='name' || name=='accessServerIp' || name=='port'){
                        params[name] = $.trim($(this).val());
                    } else if (/^[a-zA-Z]+_[2-4]$/.test(name)){
                        var array = name.split("_");
                        var index = array[1]-2;
                        if (array[1] == '3') {
                            if (order == -1) {
                                order = $(this).parents(".form-group").attr("order");
                            } else if (order != $(this).parents(".form-group").attr("order")){
                                order = $(this).parents(".form-group").attr("order");
                                num += 1;
                            }
                        }
                        index += num;
                        if (typeof(sginalServers[index]) == 'undefined') {
                            sginalServers[index]={};
                        }
                        if (array[0] == 'id' && ($(this).val() == '' || array[1] == '3')) {
                        } else if (array[0] == 'inputPort' || array[0] == 'outputPort') {
                            sginalServers[index]['port'] = $.trim($(this).val());
                        } else {
                            sginalServers[index][array[0]] = $.trim($(this).val());
                        }
                        sginalServers[index]['serverType']=array[1];
                        sginalServers[index]['sequence']=index;

                    }
                }
            });
            params['author'] = $("div.user a.name").html();
            params['sginalServers']=sginalServers;
            return {entity : JSON.stringify(params) };
        },
        add: function(data) {
            this.dao.add(data, this.onSave);
        },
        edit: function(data) {
            this.dao.edit(data, this.onSave);
        },

        onSave: function(json) {
            if (json.code == 'A00000') {
                var id = $("input[name=sginalBaseId]").val();
                var url = "";
                if (id != null) {
                    url = '/epg/sginal_home.html?id=' + id;
                } else {
                    url = '/epg/sginal_home.html';
                }

                setTimeout(function() {
                    window.location.href = url;
                }, 2000);
                var html = '操作成功，系统将在两秒后跳转到节目页面,<a href="' + url + '" target="_self">立即跳转</a>';
                $(document).tips({
                    content: html,
                    type: "loading"
                });
            } else {
                $(document).tips({
                    content: json.msg,
                    type: "error"
                });
            }

        },
        initSuggest: function() {
            var serverIpSuggest = {
                options: {
                    source: "/api/server/list",
                    method: "post",
                    multiple: false,
                    parseValue: function () {
                        var val = this.element.val(),
                            ret = []
                        return ret;
                    },
                    select: function (event, object) {
                        var item = object.item;
                        $(event.target).val(item.serverIp);
                        var server = $(event.target).attr("server");
                        $("#" + server + "Port").val(item.serverPort);
                        return false;
                    },
                    getParam: function (term) {
                        var requestData = {serverIp: term,status: 1,server_type: 2, timeSign: new Date().getTime()};
                        return requestData;
                    },

                    process: function (json) {
                        var ret = [],
                            self = this,
                            options = self.options,
                            itemData = null;
                        var data = null;
                        if (json == null) {
                            return [];
                        }
                        if (json.code === "A00000") {
                            data = $.isArray(json) ? json : json.data.result;
                        }
                        if (!data) {
                            return [];
                        }
                        $.map(data, function (item) {
                            itemData = {};
                            itemData[options.valueKey] = item["id"];
                            itemData[options.labelKey] = item["serverIp"];
                            itemData["serverIp"] = item["serverIp"];
                            itemData["serverPort"] = item["serverPort"];
                            itemData["province"] = item["province"] || "";
                            itemData["city"] = item["city"] || "";
                            itemData["remark"] = item["remark"];
                            ret.push(itemData);
                        });
                        return ret;
                    },

                    template: function (item) {
                        var formatArr = [];
                        formatArr.push('<span class="contract-width100">' + item["serverIp"] + '</span>');
                        formatArr.push('<span class="contract-width100">' + item["serverPort"] + '</span>');
                        formatArr.push('<span class="contract-width80">' + item["province"] + '</span>');
                        formatArr.push('<span class="contract-width80">' + item["city"] + '</span>');
                        formatArr.push('<span class="contract-width300">' + item["remark"] + '</span>');
                        return '<div class="contract-item" >' + formatArr.join("") + '</div>';
                    },
                    header: '<div class="contract-item" >' +
                        '<span class="contract-width100">服务器IP</span>' +
                        '<span class="contract-width100">服务器端口号</span>' +
                        '<span class="contract-width80">省份</span>' +
                        '<span class="contract-width80">市区</span>' +
                        '<span class="contract-width300">描述</span>'
                }
            };

            //$("input[name=fgIp]").suggest(serverIpSuggest.options);
            //$("input[name=idcIp]").suggest(serverIpSuggest.options);
        }
    };

});

define('../sginal/Sginal.Status',['require','exports','module'],function(require, exports, module) {
    Sginal.Status = function (options) {
        this.dao = Sginal.Dao;
        this.options = $.extend(true, {}, options);

        this.util = Sginal.Util || {};
        this.config = Sginal.config || {};
    };

    Com.inherits(Sginal.Status, Ancestor.Grid).extend({
        run: function (options, callback) {
            var self = this;
            var $container = self.options.$container;
            var gridConfig = self.getGridConfig(Sginal.Config.TABLE_STATUS, Sginal.Config.TABLE_STATUS_COLMODEL_CONFIG);
            var $form = $container.find('form[name="basicFrm"]');
            var params={};

            self.$grid = $container.find('#statusList');
            params=self.getStatusParam();
            options = $.extend(true, {
                width: 1800,
                shrinkToFit: false,
                autowidth: false,
                postData:params,
                loadComplete:function(){
                    self.$grid.find("tr").not(":first").each(function(i,ele){
                        $(ele).children().eq(0).html(params['fatherId']);
                        $(ele).children().eq(1).html(params['name']);
                    });
                }
            }, gridConfig, options);
            self.$grid.jqGrid(options);
            self.perpareData();

            self.bindFormEvent($form);
            self.bindEvent();
        },

        query: function () {
            var self = this;
            var $container = self.options.$container;
            var $grid = self.$grid;

            self.overridePostData($grid);
            var params = self.getFormParam();
            $grid.jqGrid('setGridParam', {
                postData: params,
                loadComplete:function(){
                    $grid.find("tr").not(":first").each(function(i,ele){
                        $(ele).children().eq(0).html(params['fatherId']);
                        $(ele).children().eq(1).html(params['name']);
                    });
                }
            }).trigger('reloadGrid', [{
                page: 1,
            }]);


        },

        perpareData: function () {
            var self = this;
            var username = $("div.user a.name").html();
        },


        bindEvent: function () {
            var self = this;
            var $container = self.options.$container;
            var $submit = $container.find('.query-btn');


            $submit.on('click', function () {
                self.query();
                return false;
            });
        },

        getStatusParam: function () {
            var $container = this.options.$container;
            var self = this;
            var info = location.search.slice(1);
            var param = {};
            if (info.length > 0) {
                var fatherId = info.split("&")[0].split("=")[1];
                var serverIp = info.split("&")[1].split("=")[1];
                var name = decodeURI(info.split("&")[2].split("=")[1]);
                $container.find('#today').click();
                param['fatherId'] = fatherId;
                param['serverIp'] = serverIp;
                param['name']= name;
                param['startDate']=$("input[name='startDate']").val();
                param['endDate']=$("input[name='endDate']").val();
                $("input[name='fatherId']").val(fatherId);
                $("input[name='serverIp']").val(serverIp);
                $("input[name='name']").val(name);

            }
            return param;
        },

        getFormParam: function () {
            var $container = this.options.$container;
            var self = this;
            var $form = $container.find('form[name="basicFrm"]');
            var info = location.search.slice(1);
            var param = {};
            if (info.length > 0) {
                param['name']=info.split("&")[2].split("=")[1];
            }

            $form.find('input').each(function(i,ele){
                if(i==0){
                    var fatherId = $(ele).val().trim();
                    param['fatherId']=fatherId;
                }

                if(i==1){
                    var serverIp = $(ele).val().trim();
                    param['serverIp']=serverIp;
                }

                if(i==2){
                    var startDate = $(ele).val().trim();
                    param['startDate']=startDate;
                }

                if(i==3){
                    var endDate = $(ele).val().trim();
                    param['endDate']=endDate;
                }

                if(i==4){
                    var name = $(ele).val().trim();
                    param['name']=name;
                }
            });


            return param;
        },

        bindFormEvent: function($form) {
            var self = this;
            $form.find('input[name="startDate"]').datetimepicker({
                onClose: function(selectedDate) {
                    $form.find('input[name="endDate"]').datepicker("option", "minDate", selectedDate);
                },

            });

            $form.find('input[name="endDate"]').datetimepicker({
                onClose: function(selectedDate) {
                    $form.find('input[name="startDate"]').datepicker("option", "maxDate", selectedDate);
                },

            });

            fillFieldNameWhenChangeSelect($form, 'query-select-control', 'query-input-text');
        },

    });
});

/**
 * Copyright 2015 Qiyi.com All rights reserved.
 *
 * file: epg.js
 * path: js-src/
 * description: epg业务合并文件，通过该文件引入业务功能模块的js文件
 *              配置文件将用来生成合并文件
 * author: jiegang@qiyi.com
 * date: 2015-1-6
 */
define(
    'dadian', [
        "../ancestor/Ancestor",
        "../ancestor/Ancestor.Dao",
        "../ancestor/Ancestor.Grid",
        "../ancestor/Ancestor.Config",
        "../ancestor/Ancestor.Util",
        "../ancestor/Ancestor.Dao",
        "../epg2/EpgWeb",
        "../epg2/EpgWeb.Util",
        "../epg2/EpgWeb.Plugin",
        "../epg2/EpgWeb.Dao",
        "../epg2/EpgWeb.Task",
        "../epg2/EpgWeb.PingBack",
        "../epg2/EpgWeb.PingBackCost",
        "../vod/VOD",
        "../vod/VOD.Action",
        "../vod/VOD.Config",
        "../vod/VOD.Util",
        "../vod/VOD.Plugin",
        "../vod/VOD.Evt",
        "../vod/VOD.Dao",
        "../vod/VOD.Edit",
        "../vod/VOD.NewsEdit",
        "../vod/VOD.Player",
        "../vod/VOD.NewsHighlight",
        "../vod/VOD.AccurateFrame",
        "../vod/VOD.Advert",
        "../vod/VOD.Task",
        "../specimenCollection/Specimen",
        "../specimenCollection/Specimen.Action",
        "../specimenCollection/Specimen.Config",
        "../specimenCollection/Specimen.Dao",
        "../specimenCollection/Specimen.Edit",
        "../specimenCollection/Specimen.Util",
        "../specimenCollection/Specimen.Grid",
        "../specimenCollection/Specimen.Grid",
        "../vodad/Vodad",
        "../vodad/Vodad.Action",
        "../vodad/Vodad.Config",
        "../vodad/Vodad.Dao",
        "../vodad/Vodad.Util",
        "../vodad/Vodad.Grid",
        "../server/Server",
        "../server/Server.Action",
        "../server/Server.Config",
        "../server/Server.Dao",
        "../server/Server.Util",
        "../server/Server.Grid",
        "../server/Server.Edit",
        "../server/Server.Version",
            "../server/Server.ClusterList",
            "../server/Server.ClusterEdit",
        "../sginal/Sginal",
        "../sginal/Sginal.Action",
        "../sginal/Sginal.Config",
        "../sginal/Sginal.Dao",
        "../sginal/Sginal.Util",
        "../sginal/Sginal.Grid",
        "../sginal/Sginal.Edit",
            "../sginal/Sginal.Status"
    ],

    function() {
        console.log('dadian load done:', 'dadian');
        if (SystemDialog && SystemDialog.initSystemDialog) {
            SystemDialog.initSystemDialog();
        }
    }
);

